Zostel
Forms Checkbox

Checkbox

Yes or no — one at a time, or many in a list (Radix Checkbox).

Preview

Default

Filter by amenity

Disabled

Usage

tsx
import { Checkbox, Label } from "zostel-ui";

<div className="flex items-center gap-2">
  <Checkbox id="rules" aria-labelledby="rules-label" onCheckedChange={(checked) => setAgreed(checked === true)} />
  <Label id="rules-label" htmlFor="rules">I've read the house rules</Label>
</div>

Props

checked / defaultChecked
Type: boolean | "indeterminate"
Default: —

Controlled / uncontrolled state.

onCheckedChange
Type: (checked: boolean | "indeterminate") => void
Default: —

Called when it changes.

disabled
Type: boolean
Default: false

Greys it out. On a touch screen its target is 44 px (an invisible band, so it keeps its look); give rows 44 px between them so each target is its own.

id · aria-label · aria-labelledby
Type: string
Default: —

Its name, required: an id that a <Label htmlFor> points at, aria-labelledby (the id of the words beside it) or aria-label. A <label> alone names it in browsers, but axe doesn’t count a label for these button-based controls: pair htmlFor (a click on the words reaches it) with aria-labelledby, as the preview does. In a form, FormControl does both with FormLabel. In development, one that renders with no name warns in the console.

className
Type: string
Default: —

More classes, merged with the component’s own (tailwind-merge).