Skip to content

FormCheckbox

Props

value
required
Checkbox value
type:[String, Object]
indeterminate
Is it marked as an indeterminate
type:Boolean
default:false

Slots

default
Default slot for label for checkboxa

Events

update:modelValue
Updating model

Examples

Standard list with one checkbox marked

Returned value:

[ "1" ]

html
<form-field name="islist" :model="islist" template="checkbox">
  <form-checkbox value="1">
    <form-label text="Your first choice" />
  </form-checkbox>
  <form-checkbox value="2">
    <form-label text="Your second choice" />
  </form-checkbox>
  <form-valid />
</form-field>
ts
const islist = useField('islist', toFieldValidator(zod.string().array().nonempty()), {
  initialValue: ['1']
})
Single, with a different location of the error

Returned value:

[]

html
<form-field name="isone" :model="isone" template="checkbox">
  <form-checkbox value="confirm">
    <form-label text="Whether to agree" />
    <form-valid />
  </form-checkbox>
</form-field>
ts
const isone = useField(
  'isone',
  toFieldValidator(zod.string().array().nonempty('You must agree to this consent')),
  { initialValue: [] }
)

WARNING

The component for proper operation requires placing in the component FormField.

Validation

Checkbox validation is always based on the list.