Checkbox
import { Checkbox } from '@tangible/ui';
Interactive docs and examples: Checkbox in Storybook.
Checkbox props
| Prop | Type | Default | Description |
|---|---|---|---|
checked? |
boolean |
||
className? |
string |
||
defaultChecked? |
boolean |
false |
|
disabled? |
boolean |
||
indeterminate? |
boolean |
false |
|
label? |
ReactNode |
When provided, renders the checkbox inside a <label> with this content. When omitted, renders a bare <input> — you must provide an accessible name via aria-label, aria-labelledby, or a wrapping Field.Control + Field.Label. |
|
onCheckedChange? |
(checked: boolean) => void |
Also accepts the standard attributes of InputHTMLAttributes (data-*, aria-*, event handlers), passed to the element it renders.
Examples
-
Basic: Default unchecked state with visible label.
-
Bare: Bare checkbox with no visible label — requires
aria-labelfor accessibility. -
Checked: Checked by default using
defaultChecked. -
Indeterminate: Indeterminate state — commonly used as a "select all" parent in a checkbox group.
-
Controlled: Controlled checkbox — parent owns the checked state.
-
Indeterminate Toggle: Select-all pattern with indeterminate parent. Uses
<fieldset>/<legend>for grouping. -
With Field: Checkbox inside a Field — the
labelprop handles the visible inline label. SkipField.Label(checkbox is self-labelling).Field.Controlstill injectsaria-describedby(helper/error) andaria-invalid— the name wiring is the only part that doesn't apply. -
With Field Error: Error state —
Field.Controlinjectsaria-invalid="true"andaria-describedbypointing to the error. Thelabelprop provides the visible inline label. NoField.Labelneeded. -
Multiple Options: Multiple related checkboxes grouped with
<fieldset>/<legend>.
Other stories: Disabled, Disabled Checked (interactive page).
Component API tokens
Read via fallback, never declared. Set one on an ancestor to restyle every instance under it.
--tui-checkbox-accent--tui-checkbox-border--tui-checkbox-border-hover--tui-checkbox-border-invalid--tui-checkbox-radius--tui-checkbox-bg--tui-checkbox-size--tui-checkbox-gap--tui-checkbox-label-color