File: checkbox.md | Updated: 11/15/2025
ThemesThemes PrimitivesPrimitives IconsIcons ColorsColors
Documentation Case studies Blog
Search
/
Introduction Getting started Accessibility Releases
Styling Animation Composition Server-side rendering
Accordion
Alert Dialog
Aspect Ratio
Avatar
Checkbox
Collapsible
Context Menu
Dialog
Dropdown Menu
Form
Preview
Hover Card
Label
Menubar
Navigation Menu
One-Time Password Field
Preview
Password Toggle Field
Preview
Popover
Progress
Radio Group
Scroll Area
Select
Separator
Slider
Switch
Tabs
Toast
Toggle
Toggle Group
Toolbar
Tooltip
Accessible Icon Direction Provider Portal Slot Visually Hidden
Components
A control that allows the user to toggle between checked and not checked.
Accept terms and conditions.
index.jsxindex.jsxstyles.cssstyles.css
CSS
import * as React from "react";
import { Checkbox } from "radix-ui";
import { CheckIcon } from "@radix-ui/react-icons";
import "./styles.css";
const CheckboxDemo = () => (
<form>
<div style={{ display: "flex", alignItems: "center" }}>
<Checkbox.Root className="CheckboxRoot" defaultChecked id="c1">
<Checkbox.Indicator className="CheckboxIndicator">
<CheckIcon />
</Checkbox.Indicator>
</Checkbox.Root>
<label className="Label" htmlFor="c1">
Accept terms and conditions.
</label>
</div>
</form>
);
export default CheckboxDemo;
Supports indeterminate state.
Full keyboard navigation.
Can be controlled or uncontrolled.
Install the component from your command line.
npm install @radix-ui/react-checkbox
Import all parts and piece them together.
import { Checkbox } from "radix-ui";
export default () => (
<Checkbox.Root>
<Checkbox.Indicator />
</Checkbox.Root>
);
Contains all the parts of a checkbox. An input will also render when used within a form to ensure events propagate correctly.
| Prop | Type | Default |
| --- | --- | --- |
| asChild<br><br>Prop description | boolean | false |
| defaultChecked<br><br>Prop description | boolean \| 'indeterminate' | No default value |
| checked<br><br>Prop description | boolean \| 'indeterminate' | No default value |
| onCheckedChange<br><br>Prop description | function<br><br>See full type | No default value |
| disabled<br><br>Prop description | boolean | No default value |
| required<br><br>Prop description | boolean | No default value |
| name<br><br>Prop description | string | No default value |
| value<br><br>Prop description | string | on |
| Data attribute | Values |
| --- | --- |
| [data-state] | "checked" \| "unchecked" \| "indeterminate" |
| [data-disabled] | Present when disabled |
Renders when the checkbox is in a checked or indeterminate state. You can style this element directly, or you can use it as a wrapper to put an icon into, or both.
| Prop | Type | Default |
| --- | --- | --- |
| asChild<br><br>Prop description | boolean | false |
| forceMount<br><br>Prop description | boolean | No default value |
| Data attribute | Values |
| --- | --- |
| [data-state] | "checked" \| "unchecked" \| "indeterminate" |
| [data-disabled] | Present when disabled |
You can set the checkbox to indeterminate by taking control of its state.
import { DividerHorizontalIcon, CheckIcon } from "@radix-ui/react-icons";
import { Checkbox } from "radix-ui";
export default () => {
const [checked, setChecked] = React.useState("indeterminate");
return (
<>
<StyledCheckbox checked={checked} onCheckedChange={setChecked}>
<Checkbox.Indicator>
{checked === "indeterminate" && <DividerHorizontalIcon />}
{checked === true && <CheckIcon />}
</Checkbox.Indicator>
</StyledCheckbox>
<button
type="button"
onClick={() =>
setChecked((prevIsChecked) =>
prevIsChecked === "indeterminate" ? false : "indeterminate",
)
}
>
Toggle indeterminate
</button>
</>
);
};
Adheres to the tri-state Checkbox WAI-ARIA design pattern .
| Key | Description | | --- | --- | | Space | Checks/unchecks the checkbox. |
PreviousAvatar
NextCollapsible