Components
Checkbox
Accessible checkbox with optional label, description, and an indeterminate state.
Checkbox toggles a boolean. Pass checked and onChange to control it, or
defaultChecked to leave it uncontrolled; onChange receives the next boolean
directly. Provide a label (and optional description) to render the text
beside it, fully wired for accessibility. Set indeterminate for the mixed
state used by "select all" parents. Built on Headless UI for keyboard and focus
handling.
Example
Preview
Works standalone or inside tables and forms.
import { Checkbox } from '@officina/ui';
import { useState } from 'react';
function Example() {
const [checked, setChecked] = useState(false);
return (
<Checkbox
checked={checked}
onChange={setChecked}
label="Subscribe to updates"
description="One email a week, no spam."
/>
);
}API
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | Controlled checked state. |
| description | string | — | Secondary helper text under the label. |
| disabled | boolean | — | Disable interaction and dim the control. |
| indeterminate | boolean | — | Render the mixed/indeterminate visual state. |
| invalid | boolean | — | Marks the field invalid for validation styling and `aria-invalid`. |
| label | string | — | Visible label beside the checkbox. |
| name | string | — | Form field name, for native form submission / form libraries. |
| onChange | (checked: boolean) => void | — | Called with the new checked state on toggle. |
| required | boolean | — | Marks the field as required for validation styling and `aria-required`. |