Form Group
Form groups are the easiest way to add structure to form elements.
Example
The <i-form-group>
component is a wrapper that provides proper grouping of labels, input, help text, and form validation messaging. By default, form groups add a margin-bottom
to provide spacing between form groups.
<i-form-group>
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group>
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group>
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
<i-form-group>
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group>
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline',
};
}
}
Disabled State
Setting a form group as disabled
will cause all of its child inputs to be disabled.
<i-form-group disabled>
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group disabled>
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group disabled>
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
<i-form-group disabled>
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group disabled>
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
Sizes
You're able to use the size
modifier to control the size of the components inside your <i-form-group>
, using one of the available sizes: sm
, md
, and lg
. The default size is set to md
.
All of the components inside the <i-form-group>
will inherit the parent form group's size.
<i-form-group size="sm">
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group size="sm">
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group size="sm">
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
<i-form-group size="sm">
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group size="sm">
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
<i-form-group size="md">
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group size="md">
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group size="md">
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
<i-form-group size="md">
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group size="md">
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
<i-form-group size="lg">
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group size="lg">
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group size="lg">
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
<i-form-group size="lg">
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group size="lg">
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
Form Group Nesting
You can nest form groups in order to control the disabled
, readonly
and size
properties of multiple inputs at once. All the child inputs of the parent form group will inherit the property.
<i-form-group disabled>
<i-form-group>
<i-form-label>Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group>
<i-form-label>Input</i-form-label>
<i-input v-model="password" type="password" placeholder="Enter your password.." />
</i-form-group>
</i-form-group>
export default {
data () {
return {
input: '',
password: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
<i-form-group readonly>
<i-form-group>
<i-form-label>Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group>
<i-form-label>Select</i-form-label>
<i-select v-model="select" placeholder="Choose an option">
<i-select-option value="a" label="Option A" />
<i-select-option value="b" label="Option B" />
<i-select-option value="c" label="Option C" disabled />
</i-select>
</i-form-group>
</i-form-group>
export default {
data () {
return {
input: '',
password: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
<i-form-group size="lg">
<i-form-group>
<i-form-label>Checkbox</i-form-label>
<i-checkbox-group v-model="checkbox">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group>
<i-form-label>Radio</i-form-label>
<i-radio-group v-model="radio">
<i-radio value="Accept">Accept</i-radio>
<i-radio value="Decline">Decline</i-radio>
</i-radio-group>
</i-form-group>
</i-form-group>
export default {
data () {
return {
input: '',
password: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
Component API
Here you can find a list of the various customization options you can use for the form group components as props, as well as available slots.
Boolean
true
, false
false
Boolean
true
, false
false
String
sm
, md
, lg
md
Boolean
true
, false
false
Boolean
true
, false
true
Sass Variables
Here you can find a list of the Sass variables you can use for the form group component. If you're looking to find common variables that these rely on, you should take a look at the Sass Variables page.
$spacer
($spacer / 4) 0 0