Skip to content

Checkbox

The styled checkbox, with tri-state support (true, false, "indeterminate").

<script>
import Checkbox from "@invisible-ui/svelte/Checkbox.svelte";
</script>
PropTypeDefaultDescription
label *string—Accessible, visible label; override with children.
hideLabelbooleanfalseVisually 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.
checkedCheckedStatefalseChecked state (tri-state).
disabledbooleanfalseDisable the control.
namestring | undefinedundefinedForm field name; the value is submitted under it when checked.
valuestring"on"Value submitted with the form when checked.
requiredbooleanfalseMark the control required for native form validation.
onCheckedChange((c: CheckedState) => void) | undefinedundefinedCalled whenever the checked value changes.
  • Built on a native <input type="checkbox">: the browser provides the checkbox role, aria-checked (including mixed via the indeterminate property), Space activation, focus and form participation. data-state mirrors the value for styling.
  • A label is required; the native input is wrapped in a <label>, so the visible text names the control and clicking it toggles the box.
<Checkbox label="Accept terms" onCheckedChange={(c) => setAccepted(c)} />

Themeable via --ds-checkbox-*.