Checkbox

The Checkbox component is a versatile form control for selecting one or multiple options.

Usage

Default

<Checkbox label="Accept Terms" checked={checked} onChange={...} />

Props

Data table
TypeDescription
aria-describedbystringID reference(s) to element(s) that describe the checkbox. This may include helper text, error text, or external descriptions.
aria-errormessagestringID reference to the element containing the error message. Typically used together with aria-invalid.
aria-labelstringAccessible label for the checkbox when no visible label is present or when a more descriptive label is needed.
aria-labelledbystringID reference(s) to element(s) that label the checkbox. If provided, this takes precedence over the internal label association.
checkedbooleanChecked state of the checkbox.
classNamestringCustom class name for additional styling.
data-testidstringOptional test ID for testing frameworks.
descriptionReactNodeVisible helper text rendered below or beside the checkbox. Should provide extra guidance for the user.
disabledbooleanWhether the checkbox is disabled.
errorMessageReactNodeVisible error message rendered for invalid state. This can also be referenced by assistive technologies.
indeterminatebooleanWhether the checkbox is in an indeterminate (mixed) state.
invalidbooleanMarks the checkbox as invalid. Useful when validation fails.
labelReactNodeLabel text displayed beside the checkbox.
labelPosition"left" | "right"Position of the label relative to the checkbox ('left' | 'right').
onChange(checked: boolean) => voidCallback when the checkbox value changes.
requiredbooleanWhether the checkbox is required.
role"checkbox"Optional role override, though checkbox is the default semantic role.
roundingRoundingTypeControls the rounding of the checkbox ('none' | 'small' | 'medium' | 'large' | 'full').
shadowShadowTypeControls the shadow of the checkbox ('none' | 'light' | 'medium' | 'strong' | 'intense').
sizeSizeTypeSize of the checkbox ('xs' | 'small' | 'medium' | 'large' | 'xl').
stateStateTypeState of the checkbox ('success' | 'error' | 'warning' | 'disabled' | '').
themeThemeTypeOptional theme to style the checkbox ('primary' | 'secondary' | 'tertiary' | 'quaternary' | 'clear').