AisCheckbox
AisCheckbox is a branded checkbox component that ensures a label is attached to the checkbox.
v-model
Single checkbox
At its most basic, use v-model to bind a single checkbox to a boolean value. The body of AisCheckbox will be used as the checkbox's label.
Multiple checkboxes
Values from related checkboxes may be collated using v-model to bind an array to each checkbox. Each element in the group should specify a value using the value prop. If the form will be submitted, the checkboxes should also share a name.
Selection: [
"Two"
]
Props
modelValue
modelValue powers the prop side of v-model. It works in conjunction with the @update:modelValue event. See the VueJS documentation for details.
value
The value prop sets the input element's value. When v-model is bound to an array, this is the value that will be added when checked. This is also the value that will be sumbitted if the form is submitted to a server.
checked
checked is a boolean prop that reflects the whether the checkbox is checked or not.
label
The label prop is set as the default value for the default slot. Developers may use either though any text provided in the body of the tag will override the label prop. When defining an iconOnly checkbox, you should prefer this prop as it will also be used to generate a tooltip. All checkboxes should specify either a label prop or a tag body to properly define an accessible label.
icon
AisCheckbox accepts an icon prop to display an icon alongside the checkbox. icon will accept either a FontAwesome icon definition or a string for one of our standard icons.
iconOnly
iconOnly is a boolean prop that defaults to false. When true, the checkbox's label will only be shown to screen readers, and a tooltip will be shown on hover. When using iconOnly, prefer the label prop instead of the default slot. Any tooltip specification will take precedence. However, if tooltip is not specified, then the label prop will be used as the tooltip.
tooltip
The tooltip prop will specify a tooltip for a checkbox. The prop may take either a boolean value, variant (e.g. "primary" or "success"), string (content text), or a tooltip options object. When passed true or a variant, the label prop will be used for the tooltip text.
size
Checkboxes accept a size property with the standard values of sm, md, and lg. Medium (md) is the default.
name
The name prop will set the name attribute on the checkbox. It is required if the form will be submitted to a server. It is also recommended to provide a name when iterating over a list of options to create a checkbox group.
disabled
Checkboxes accept a boolean disabled property. Disabled checkboxes are not clickable and are not submitted with its form.
invalid
Checkboxes accept a boolean invalid and flagError properties to highlight and customize invalid checkboxes. When invalid is true, the checkbox will be styled with a red border. If flagError is true (as it is by default), the error icon will also appear. AisCheckboxGroup disables flagError as it handles error styling at the group level.
required
The required prop marks the checkbox as required and activates browser validation. If a checkbox is required, then it must be checked to satisfy the browser validation. This is true whether the checkbox stands alone or is part of a same name group. As a result, checkboxes will not inherit required status from AisField or other ancestors. Checkboxes must be explicitly marked as required through the prop.
Events
@update:modelValue
@update:modelValue fires when the checkbox changes and drives the v-model directive. See the VueJS documentation for details.
@change
The @change event fires when the checkbox is checked or unchecked. The event's payload contains the checkbox's checked status and the checkbox's value. If the value is a number, the raw value can be found in the intValue attribute.
Payload: {}