Checkbox
Terminal-style checkbox with [X] indicator for boolean selections.
Import
Basic Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | — | Whether the checkbox is checked (controlled) |
defaultChecked | boolean | false | Default checked state (uncontrolled) |
onCheckedChange | (checked: boolean) => void | — | Callback when checked state changes |
label | string | — | Label text displayed next to checkbox |
disabled | boolean | false | Whether the checkbox is disabled |
name | string | — | Name attribute for forms |
value | string | — | Value attribute for forms |
className | string | — | Additional CSS class names |
ref | React.Ref<HTMLButtonElement> | — | Forwarded ref to the button element |
With Label
Checkbox Group
Disabled States
Controlled Checkbox
State: Unchecked
Multiple Selections Example
For multiple selections, manage state manually:
Visual Design
The checkbox uses a terminal-style indicator:
- Unchecked:
[ ] - Checked:
[X]
Keyboard Navigation
| Key | Action |
|---|---|
Space | Toggle checked state |
Enter | Toggle checked state |
Tab | Move focus to next element |
Accessibility
- Built on Base UI's accessible checkbox primitive
- Proper ARIA attributes for screen readers
- Keyboard accessible
- Label properly associated with checkbox
Styling
| Variable | Description |
|---|---|
--theme-border | Checkbox border color |
--theme-text | Indicator and label color |
--theme-focused-border | Border color when focused |