Form
Forms are the main wrapper components for form elements, with powerful customization and validation options.
Basic Form
The <i-form>
component is a wrapper that provides proper handling of form validation and form grouping.
Form
<i-form>
<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>
<i-form-group>
<i-button type="submit">Submit</i-button>
</i-form-group>
</i-form>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline',
};
}
}
Disabled State
Setting a form as disabled
will cause all of its child inputs to be disabled.
Disabled Form
<i-form disabled>
<i-form-group>
<i-form-label>Disabled Input</i-form-label>
<i-input v-model="input" placeholder="Type something.." />
</i-form-group>
<i-form-group>
<i-form-label>Disabled Textarea</i-form-label>
<i-textarea v-model="textarea" placeholder="Write a comment.." />
</i-form-group>
<i-form-group>
<i-form-label>Disabled 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>Disabled 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">Tennis</i-checkbox>
</i-checkbox-group>
</i-form-group>
<i-form-group>
<i-form-label>Disabled 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>
<i-button type="submit">Submit</i-button>
</i-form-group>
</i-form>
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>
, 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>
will inherit the parent form group's size.
Small Form Size
<i-form size="sm">
<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>
<i-form-group>
<i-button type="submit">Submit</i-button>
</i-form-group>
</i-form>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
Medium Form Size
<i-form size="md">
<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>
<i-form-group>
<i-button type="submit">Submit</i-button>
</i-form-group>
</i-form>
export default {
data () {
return {
input: '',
textarea: '',
select: '',
checkbox: ['Football'],
radio: 'Decline'
};
}
}
Large Form Size
<i-form size="lg">
<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>
<i-form-group>
<i-button type="submit">Submit</i-button>
</i-form-group>
</i-form>
export default {
data () {
return {
input: '',
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 components as props, as well as available slots and events.
Form API
Property disabled
Type
Boolean
Accepted
true
, false
Default
false
Description Sets the state of the form component as disabled.
Property readonly
Type
Boolean
Accepted
true
, false
Default
false
Description Sets the state of the form component as readonly.
Property schema
Type
Object
Description Provides a schema binding to the form component. See the Form Validation documentation.
Property size
Type
String
Accepted
sm
, md
, lg
Default
md
Description Sets the size of the form component.
Property inline
Type
Boolean
Accepted
true
, false
Default
false
Description Sets the form styling to be inline.
Slot default
Description Slot for form default content.
Event submit
Type
(event: Event) => {}
Description Emitted when form is submitted.
Event validate
Type
(event: Event) => {}
Description Emitted when form is validated.