Form
Checkbox
A native checkbox under a drawn box, bound to a boolean or to an array of values, with a mixed state.
WAI-ARIA tested
Import
main.ts
import { Checkbox } from '@vitral/vue';Binary
accepted: false, newsletter: no
Group and mixed state
The parent box is indeterminate while only some toppings are chosen.
Toppings[
"cheese"
]
Rich content
Sizes and states
API
Read from packages/vue/src/components/Checkbox/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| value | any | The value this box adds to an array v-model when checked. Leave it out (or set `binary`) and v-model is a boolean instead. |
| binary | boolean | v-model is a single checked/unchecked value rather than an array. Implied when there is no `value`. |
| trueValue | any | What a checked binary box sets v-model to. Defaults to true. |
| falseValue | any | What an unchecked binary box sets v-model to. Defaults to false. |
| label | string | The text beside the box; the default slot takes richer content. Either becomes its `<label>`. |
| size | Size | — |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| change | event: CheckboxChangeEvent | — |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| default | — | The label's content. |
| icon | (props: { checked: boolean; indeterminate: boolean }) | Replaces the check (and the dash of the mixed state). |