Checkbox
A high-quality, unstyled React checkbox component that is easy to customize.
An easily stylable checkbox component.
Usage guidelines
- Form controls must have an accessible name: It can be created using a
<label>element or theFieldcomponent. See Labeling a checkbox and the forms guide.
Anatomy
Import the component and assemble its parts:
import { Checkbox } from '@base-ui/react/checkbox';
<Checkbox.Root>
<Checkbox.Indicator />
</Checkbox.Root>;Examples
Labeling a checkbox
An enclosing <label> is the simplest labeling pattern:
<label>
<Checkbox.Root />
Accept terms and conditions
</label>Rendering as a native button
By default, <Checkbox.Root> renders a <span> element to support enclosing labels. Prefer rendering the checkbox as a native button when using sibling labels (htmlFor/id).
<div>
<label htmlFor="notifications-checkbox">Enable notifications</label>
<Checkbox.Root id="notifications-checkbox" nativeButton render={<button />}>
<Checkbox.Indicator />
</Checkbox.Root>
</div>Native buttons with wrapping labels are supported by using the render callback to avoid invalid HTML, so the hidden input is placed outside the label:
<Checkbox.Root
nativeButton
render={(buttonProps) => (
<label>
<button {...buttonProps} />
Enable notifications
</label>
)}
/>Form integration
Use Field to handle label associations and form integration:
<Form>
<Field.Root name="stayLoggedIn">
<Field.Label>
<Checkbox.Root />
Stay logged in for 7 days
</Field.Label>
</Field.Root>
</Form>API reference
Root
| Name | Type | Default | Description |
|---|---|---|---|
idOptional | string | undefined | — | The id of the input element. |
nameOptional | string | undefined | undefined | Identifies the field when a form is submitted. |
checkedOptional | boolean | undefined | undefined | Whether the checkbox is currently ticked. To render an uncontrolled checkbox, use the `defaultChecked` prop instead. |
defaultCheckedOptional | boolean | undefined | false | Whether the checkbox is initially ticked. To render a controlled checkbox, use the `checked` prop instead. |
disabledOptional | boolean | undefined | false | Whether the component should ignore user interaction. |
readOnlyOptional | boolean | undefined | false | Whether the user should be unable to tick or untick the checkbox. |
requiredOptional | boolean | undefined | false | Whether the user must tick the checkbox before submitting a form. |
indeterminateOptional | boolean | undefined | false | Whether the checkbox is in a mixed state: neither ticked, nor unticked. |
inputRefOptional | React.Ref<HTMLInputElement> | undefined | — | A ref to access the hidden `<input>` element. |
parentOptional | boolean | undefined | false | Whether the checkbox controls a group of child checkboxes. Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group). |
uncheckedValueOptional | string | undefined | — | The value submitted with the form when the checkbox is unchecked. By default, unchecked checkboxes do not submit any value, matching native checkbox behavior. |
valueOptional | string | undefined | — | The value of the selected checkbox. |
Indicator
| Name | Type | Default | Description |
|---|---|---|---|
keepMountedOptional | boolean | undefined | false | Whether to keep the element in the DOM when the checkbox is not checked. |