Checkbox
The styled checkbox, with tri-state support (true, false, "indeterminate").
Import
Section titled “Import”<script> import Checkbox from "@invisible-ui/svelte/Checkbox.svelte";</script><script setup> import { Checkbox } from "@invisible-ui/vue";</script>import { Checkbox } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-checkbox></ds-checkbox>| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible, visible label; override with children. |
hideLabel | boolean | false | Visually hide the label while keeping it as the accessible name (for a checkbox whose meaning is carried by its surroundings, e.g. a selection column). The label text is always required. |
checked | CheckedState | false | Checked state (tri-state). |
disabled | boolean | false | Disable the control. |
name | string | undefined | undefined | Form field name; the value is submitted under it when checked. |
value | string | "on" | Value submitted with the form when checked. |
required | boolean | false | Mark the control required for native form validation. |
onCheckedChange | ((c: CheckedState) => void) | undefined | undefined | Called whenever the checked value changes. |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible, visible label (required). Override with the default slot for rich content. |
hideLabel | boolean | false | Visually hide the label while keeping it as the accessible name (for a checkbox whose meaning is carried by its surroundings, e.g. a selection column). The label text is always required. |
modelValue | CheckedState | undefined | v-model value; takes precedence over checked when bound. |
checked | CheckedState | false | |
disabled | boolean | false | |
name | string | undefined | Form field name; the value is submitted under it when checked. |
value | string | "on" | Value submitted with the form when checked. Defaults to the native "on". |
required | boolean | false | Mark the control required for native form validation. |
onCheckedChange | (checked: CheckedState) => void | undefined | Called whenever the checked value changes. |
| Event | Payload |
|---|---|
update:modelValue | checked: CheckedState |
Slots: default.
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible, visible label (required). Override with children for rich content. |
hideLabel | boolean | false | Visually hide the label while keeping it as the accessible name. The label text is always required. |
checked | CheckedState | false | |
disabled | boolean | false | |
name | string | — | Form field name — the value is submitted under it when checked. |
value | string | "on" | Value submitted with the form when checked. Defaults to the native "on". |
required | boolean | false | Mark the control required for native form validation. |
onCheckedChange | (checked: CheckedState) => void | — | Called whenever the checked value changes. |
children | ReactNode | — |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | |
hide-label | yes | |
checked | yes | |
indeterminate | yes | |
disabled | yes | |
name | yes | |
value | yes | |
required | yes | |
description | yes | |
error | yes |
Reactive attributes re-render the element when they change after the first render.
Properties: checked (boolean | "indeterminate").
Emits: bubbling change CustomEvent with detail.checked.
Accessibility
Section titled “Accessibility”- Built on a native
<input type="checkbox">: the browser provides the checkbox role,aria-checked(includingmixedvia the indeterminate property), Space activation, focus and form participation.data-statemirrors the value for styling. - A
labelis required; the native input is wrapped in a<label>, so the visible text names the control and clicking it toggles the box.
Example
Section titled “Example”<Checkbox label="Accept terms" onCheckedChange={(c) => setAccepted(c)} />Themeable via --ds-checkbox-*.