Checkbox

Binary toggle for form fields. Use for options that require explicit submission, unlike Switch which takes effect immediately.

Setup

import { Checkbox } from '@fragments-sdk/ui';

Examples

Default

Basic checkbox with label

Loading preview...

With Helper Text

Checkbox with helper text

Loading preview...

Checked

Pre-checked checkbox

Loading preview...

Indeterminate

Partial selection state

Loading preview...

Sizes

Available size options

Loading preview...

Disabled

Non-interactive states

Loading preview...

Custom Styling Targets

Use explicit class targets for control vs content styling

Loading preview...

Props

PropTypeDefaultDescription
checkedbooleanNot setControlled checked state
defaultCheckedbooleanNot setDefault checked state (uncontrolled)
onCheckedChangefunctionNot setCalled when checked state changes
onChangefunctionNot setAlias for onCheckedChange: (checked: boolean) => void
indeterminatebooleanfalseIndeterminate state (partial selection)
disabledbooleanfalseDisable the checkbox
readOnlybooleanfalseWhether the checkbox cannot be changed by the user
requiredbooleanfalseWhether the checkbox is required
sizeenumsmmdlgmdCheckbox size
variantenumdefaultcarddefaultVisual variant. 'default' is the inline checkbox, 'card' renders as a full-width clickable card with the checkbox tucked inside.
labelstringNot setLabel text
helperTextstringNot setHelper text shown below the label (preferred)
descriptionstringNot setDeprecated alias for helperText
namestringNot setName attribute for form submission
formstringNot setID of the form that owns the hidden input
valuestringNot setValue attribute for form submission
uncheckedValuestringNot setValue submitted when unchecked
inputRefunionNot setRef to the hidden input element
parentbooleanNot setWhether this checkbox controls child checkboxes in a checkbox group
idstringNot setID for the checkbox input
controlClassNamestringNot setClass name for the checkbox control element (stable styling target)
contentClassNamestringNot setClass name for the label/description content wrapper
aria-labelstringNot setAccessible label for icon-only mode
aria-labelledbystringNot setAccessible labelled-by relationship for icon-only mode
aria-describedbystringNot setAccessible described-by relationship

Usage Guidelines

When to use

  • Form fields requiring explicit submission
  • Multi-select from a list of options
  • Terms and conditions acceptance
  • Filter or preference checklists

When not to use

  • Immediate effect settings (use Switch)
  • Single selection from options (use RadioGroup)
  • Selecting from many options (use Select)

Best practices

  • Always include a visible label
  • Use helperText for additional context when needed
  • Group related checkboxes visually
  • Use indeterminate state for parent/child relationships
Accessibility
  • Proper label association
  • Keyboard accessible (Space to toggle)
  • Visible focus indicator
  • Indeterminate state properly announced