--- title: Checkbox sidebar_label: Checkbox --- import { StoryWithControls } from '../../../src/components/StorybookWrapper'; # Checkbox Checkbox component that supports both regular and indeterminate states, built on top of Ant Design v5 Checkbox. ## Live Example ## Try It Edit the code below to experiment with the component: ```tsx live function Demo() { return ( ); } ``` ## All Checkbox States ```tsx live function AllStates() { return (
Unchecked Checked Indeterminate Disabled unchecked Disabled checked
); } ``` ## Select All Pattern ```tsx live function SelectAllDemo() { const [selected, setSelected] = React.useState([]); const options = ['Option A', 'Option B', 'Option C']; const allSelected = selected.length === options.length; const indeterminate = selected.length > 0 && !allSelected; return (
setSelected(e.target.checked ? [...options] : [])} > Select All
{options.map(opt => (
setSelected(prev => prev.includes(opt) ? prev.filter(x => x !== opt) : [...prev, opt] )} > {opt}
))}
); } ``` ## Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `checked` | `boolean` | `false` | Whether the checkbox is checked. | | `indeterminate` | `boolean` | `false` | Whether the checkbox is in indeterminate state (partially selected). | ## Import ```tsx import { Checkbox } from '@superset/components'; ``` --- :::tip[Improve this page] This documentation is auto-generated from the component's Storybook story. Help improve it by [editing the story file](https://github.com/apache/superset/edit/master/superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.stories.tsx). :::