Checkbox
Check, clear or mixed.
Required to continue.
In context
Native appearance
Props
| Prop | Type | Required | Default |
|---|---|---|---|
description | ReactNode | No | — |
variant | "default" | "card" | undefined | No | default |
appearance | "default" | "custom" | "native" | undefined | No | custom |
labelClassName | string | undefined | No | — |
invalid | boolean | undefined | No | — |
bionic | boolean | undefined | No | — |
bionicOptions | BionicOptions | undefined | No | — |
Accessibility
A real Radix checkbox (role="checkbox", Space toggles, a visible focus ring) inside a real <label>, so the whole row is the target. checked="indeterminate" is announced as mixed. Pass aria-label when there is no visible label.
data-rebar-* attributes
data-rebar-component="checkbox" on the control; data-rebar-part="indicator" on the mark, "label" on the text; Radix sets data-state.
Migrating to Ant Design
AntD's Checkbox takes the same checked/onChange shape (event-based) and children as its label: a close, low-risk rename.
Description and card variant
description adds a secondary line under the label, linked to the checkbox with aria-describedby. variant="card" makes the whole label a bordered card that tints when checked, for option lists such as plans or permissions.
<Checkbox variant="card" description="Billed monthly">Pro plan</Checkbox>appearance="native"
appearance="native" renders a real <input type="checkbox"> in the platform look (accent from --rebar-checkbox-native-accent), as a row with --rebar-checkbox-native-gap and -align. labelClassName styles the label.
Tokens
Custom properties, set on the component or any ancestor. The default is what applies when one is unset. 1 of 22 were added in 1.1.0 and are marked.
| Property | Default | |
|---|---|---|
--rebar-checkbox-accent | var(--rebar-checkbox-native-accent, var(--rebar-color-primary)) | |
--rebar-checkbox-card-align | flex-start | |
--rebar-checkbox-card-bg | var(--rebar-color-bg-primary, #ffffff) | |
--rebar-checkbox-card-border-color | var(--rebar-color-border, #e0e0e0) | |
--rebar-checkbox-card-border-width | 1px | |
--rebar-checkbox-card-checked-bg | color-mix(in srgb, var(--rebar-color-primary, #0066cc) 8%, var(--rebar-color-bg-primary, #ffffff)) | |
--rebar-checkbox-card-checked-border-color | var(--rebar-color-primary, #0066cc) | |
--rebar-checkbox-card-padding | var(--rebar-space-md, 16px) | |
--rebar-checkbox-card-radius | var(--rebar-radius-lg, var(--rebar-radius, 4px)) | |
--rebar-checkbox-label-align | center | |
--rebar-checkbox-label-color | inherit | 1.1 |
--rebar-checkbox-label-font-size | inherit | |
--rebar-checkbox-label-font-weight | inherit | |
--rebar-checkbox-label-gap | 10px | |
--rebar-checkbox-label-line-height | inherit | |
--rebar-checkbox-native-accent | var(--rebar-color-primary) | |
--rebar-checkbox-native-align | center | |
--rebar-checkbox-native-focus-outline | -webkit-focus-ring-color auto 1px | |
--rebar-checkbox-native-focus-outline-offset | 0px | |
--rebar-checkbox-native-gap | var(--rebar-checkbox-label-gap, 10px) | |
--rebar-checkbox-native-margin | 3px 3px 3px 4px | |
--rebar-checkbox-native-size | 20px |