Checkbox
Selects or clears one independent option.
checkbox-basic-demo.tsx
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
npm
yarn
pnpm
bun
Composition
CheckboxFieldOwns the checked state and validation.
CheckboxButtonIts text becomes the accessible name.
CheckboxIndicatorCheckboxLabel
CheckboxDescriptionCheckboxError
Checkbox Renders all of these parts from children, description, and errorMessage. Use the parts only for a custom layout.
Description
A short summary of your projects every Friday.
checkbox-description-demo.tsx
Required
The error shows after the first submit. Also install Form and Button.
checkbox-required-demo.tsx
Indeterminate
Point aria-controls at the child options.
checkbox-demo.tsx
Card
The whole card toggles the checkbox.
Keep 30 days of snapshots.
checkbox-card-demo.tsx
Disabled
checkbox-disabled-demo.tsx
API reference
vip/ui adds or changes the props below. For all other props, see React Aria Checkbox (opens in a new tab).
- children: ReactNode
- The label. Without it, pass aria-label so the checkbox has a name.
- description: ReactNode
- Help text below the label. Linked with aria-describedby, so it is not part of the name.
- errorMessage: string | ((validation: ValidationResult) => string)
- Shown below the label when isRequired, validate, or isInvalid makes the checkbox invalid. Without it, the browser validation message shows.
- checked: boolean | "indeterminate"
- Alias for isSelected. "indeterminate" sets isIndeterminate.
- defaultChecked: boolean | "indeterminate"
- Alias for defaultSelected. "indeterminate" shows the indeterminate state until the first change.
- onCheckedChange: (checked: boolean) => void
- Alias for onChange. Both run when both are set.
- variant: "default" | "card" = "default"
- Selects the plain or card appearance. A card toggles the checkbox from anywhere inside it. CheckboxField takes the same prop.