structyl

Checkbox API

View component

The full prop reference for the Checkbox component. A control that allows the user to toggle between checked, not checked, and indeterminate.

Import

tsx
import { Checkbox } from '@structyl/styled';

Props

Checkbox

The main checkbox component wrapper that combines the headless primitive with styled styling and icon indicators.

PropTypeDefault
checked#boolean | 'indeterminate'

The controlled checked state of the checkbox.

defaultChecked#boolean | 'indeterminate'

The initial checked state when uncontrolled.

onCheckedChange#(checked: boolean | 'indeterminate') => void

Callback fired when the checked state changes.

disabled#boolean

Whether the checkbox is disabled and cannot be interacted with.

false
required#boolean

Whether the checkbox is required in a form.

name#string

The name attribute for form submission; creates a hidden input if provided.

value#string

The value submitted in the form when the checkbox is checked.

'on'
color#'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success'

The color variant controlling the checked/indeterminate state background and border.

'primary'
asChild#boolean

Pass a custom element as the checkbox instead of rendering the default button.

className#string

Additional CSS classes merged with the default styling.

onClick#(event: React.MouseEvent<HTMLButtonElement>) => void

Callback fired on click; toggles checked state unless disabled.

onKeyDown#(event: React.KeyboardEvent<HTMLButtonElement>) => void

Callback fired on key down; Space toggles the checkbox, Enter is prevented.

CheckboxIndicator

A compound component that displays the check or indeterminate icon inside the checkbox, conditionally rendered based on state.

PropTypeDefault
forceMount#boolean

When true, the indicator is always rendered; when false, it only renders when checked is truthy.

asChild#boolean

Pass a custom element to replace the default span indicator container.

className#string

Additional CSS classes merged with default animation and layout styles.

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
SpaceToggles the checkbox.

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library