Tonic UI
Getting StartedColor ModeColor StyleVersionsContributing
THEME
BordersBreakpointsColorsOutlinesPositionsSpacingSizesShadowsTypography
BUILDING BLOCKS
BoxControlBox
UTILITIES

Checkbox

Use a Checkbox in forms when a user needs to select multiple values from a list of options.

Since native HTML checkboxes are 100% accessible by default, a common CSS technique is used to style checkboxes.

Import

Usage

EDITABLE EXAMPLE

Colors

Use the variantColor prop to change the color scheme of the checkbox. variantColor can be any color key with key 50 (hover) or 60 (checked, active) that exist in theme.colors.

EDITABLE EXAMPLE

Sizes

Use the size prop to change the size of the checkbox. You can set the value to sm, md, or lg.

EDITABLE EXAMPLE

States

EDITABLE EXAMPLE

Indeterminate

EDITABLE EXAMPLE

Props

NameTypeDefaultDescription
idstringThe id attribute of the input field.
namestringThe name of a input field in a checkbox. The name is useful for form submissions.
valuestring | numberThe value for checkbox input. This is the return value for form submissions.
variantColorstringThe color of the checkbox when it is selected. The color should be one of the color keys in the theme (for example, 'green', 'red')
sizestring'md'The size (width and height) of the checkbox. Acceptable values: 'sm', 'md', 'lg'
defaultCheckedbooleanIf true, the checkbox will be selected initially.
checkedbooleanIf true, the checkbox will be selected. Use onChange to update the state for a controlled component.
disabledbooleanIf true, the checkbox will be disabled. This sets aria-disabled=true and you can set this state by using the _disabled prop.
indeterminatebooleanIf true, the checkbox will be indeterminate. This only affects the icon shown inside the checkbox.
childrenReactNodeThe children of the checkbox.
onChangefunctionA callback called when the state is changed.
onBlurfunctionA callback called when the checkbox loses focus.
onFocusfunctionA callback called when the checkbox receives focus.