Diwa Design System

Checkbox

Checkboxes allow users to select one or more options from a set, or toggle a single binary choice. Supports indeterminate state for partial selection patterns.

Properties

NameTypeDefaultDescription
theme'light' | 'dark''dark'Per-component theme override. Sets data-theme on the host element so token overrides cascade into Shadow DOM.
labelstring''Visible label text rendered next to the checkbox. Also provides the accessible name for screen readers.
namestring''Field name. Emitted in the update event detail. Use for identifying the field in form data.
valuestring'on'Value emitted in the update event detail when the checkbox is checked.
checkedbooleanfalseWhether the checkbox is checked. Mutable — the component updates this prop on user interaction and also emits an update event.
indeterminatebooleanfalseShows a dash icon and sets aria-checked="mixed". Visually overrides checked. Cleared automatically when the user clicks.
disabledbooleanfalseDisables interaction and reduces opacity to 0.4. The native input receives the disabled attribute.
requiredbooleanfalseMarks the field as required with a visual asterisk in the label. Passed to the native input.
state'none' | 'error' | 'success''none'Validation state. Changes the checkbox border colour and message text colour.
messagestring''Helper or validation message. Only rendered when state is "error" or "success". Linked to the input via aria-describedby.
compactbooleanfalseEnables dense mode. Reduces checkbox size from 20 px to 14 px for dense layouts.
hide-labelbooleanfalseHides the label visually using a sr-only clip pattern. The label text is still announced by screen readers.

Events

NameDetail typeBubblesDescription
update{ checked: boolean; name: string; value: string }NoEmitted when the user toggles the checkbox. detail.checked is the new state. React consumers: use the lowercase onupdate prop (React 19 custom element event name mapping does not lowercase the event name).

Slots

diwa-checkbox has no slots. The label is provided via the label prop.

CSS custom properties

Override these tokens on the host element or a parent selector to customise the checkbox without modifying source styles.

PropertyFallbackDescription
--diwa-borderzinc-700 (dark) / zinc-300 (light)Default border colour of the unchecked checkbox box.
--diwa-accent#10a37fFill and border colour of the checked and indeterminate states.
--diwa-accent-hover#0e9470Fill colour when hovering over a checked checkbox.
--diwa-bg-hoverzinc-800 (dark) / rgba(148,149,152,0.18) (light)Background tint applied on hover of an unchecked checkbox.
--diwa-notification-error#ef4444 (dark) / #cc1922 (light)Border colour when state="error".
--diwa-notification-success#22c55e (dark) / #197e10 (light)Border colour when state="success".
--diwa-text-primary#e6e6e7 (dark) / #010205 (light)Label text colour.
--diwa-font-size-sm11pxFont size of the message text beneath the checkbox.

Form submission (V1 limitation): The inner <input name> lives inside Shadow DOM and is not visible to ancestor <form> elements for native submission. Collect checkbox values via the update event and submit programmatically. Native form participation via ElementInternals is planned for V2.