Forms

Checkbox

Boolean or tri-state control with a token-styled box. Supports color, error treatment, two sizes, label, required asterisk, and helper or error text.

Examples

States
Loading preview
<Checkbox label="Default" />
<Checkbox label="Checked" defaultChecked />
<Checkbox label="With error" error errorMessage="Required" />
Label-less (table row selector)
Loading preview
<Checkbox size="small" inputProps={{ 'aria-label': 'Select row' }} />

API

PropTypeDefaultDescription
labelReactNodenoneVisible label.
checked / defaultCheckedbooleannoneControlled or uncontrolled checked state.
indeterminatebooleanfalseMixed state, shown as a dash.
errorbooleanfalseError treatment with red box.
helperText / errorMessageReactNodenoneHelper or error text under the label.
inputPropsAriaAttributes & { 'data-testid'?: string }noneAttributes forwarded to the input — use aria-label to name a checkbox that has no visible label.
style / className / event handlersHTMLAttributes<HTMLSpanElement>noneStandard DOM props (style, className, onClick, data-*, ...) are forwarded to the root wrapper; input-only attributes go through inputProps.

Styling and attributes

Like every component, Checkbox accepts the universal token style props (m, p, sx, display, responsive maps, ...) and forwards standard DOM attributes (id, data-*, aria-*, event handlers) to the underlying element. See Styling for the full API.

Guidelines

Do

  • Always provide a label, or an accessible name via inputProps aria-label.
  • Use indeterminate for parent or select-all controls.

Avoid

  • Do not use a checkbox for mutually exclusive options; use a radio or Select.

Import from @hub/ds-components. Interactive playground: Storybook. Figma Code Connect node 101-443.