logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
6.0.0-alpha.3
  • Components Overview
  • Changelog
    v6.0.0-alpha.3
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
      DEPRECATED
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
When To Use
Examples
Basic
Disabled
Controlled Checkbox
Checkbox Group
Check all
Use with Grid
Custom semantic dom styling
API
Methods
Semantic DOM
Design Token
FAQ
Why not work in Form.Item?

Checkbox

Collect user's choices.
Importimport { Checkbox } from "antd";
GitHub
components/checkboxIssueOpen issues
Docs
Edit this page
contributors
CascaderColorPicker

Resources

Ant Design X
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

  • Used for selecting multiple values from several options.
  • If you use only one checkbox, it is the same as using Switch to toggle between two states. The difference is that Switch will trigger the state change directly, but Checkbox just marks the state as changed and this needs to be submitted.

Examples

API

Common props ref:Common props

Checkbox

PropertyDescriptionTypeDefaultVersion
autoFocusIf get focus when component mountedbooleanfalse
checkedSpecifies whether the checkbox is selectedbooleanfalse
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
defaultCheckedSpecifies the initial state: whether or not the checkbox is selectedbooleanfalse
disabledIf disable checkboxbooleanfalse
indeterminateThe indeterminate checked state of checkboxbooleanfalse
onChangeThe callback function that is triggered when the state changes(e: CheckboxChangeEvent) => void-
onBlurCalled when leaving the componentfunction()-
onFocusCalled when entering the componentfunction()-
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-

Checkbox.Group

PropertyDescriptionTypeDefaultVersion
defaultValueDefault selected value(string | number)[][]
disabledIf disable all checkboxesbooleanfalse
nameThe name property of all input[type="checkbox"] childrenstring-
optionsSpecifies optionsstring[] | number[] | Option[][]
valueUsed for setting the currently selected value(string | number | boolean)[][]
titletitle of the optionstring-
classNameclassName of the optionstring-5.25.0
stylestyles of the optionReact.CSSProperties-
onChangeThe callback function that is triggered when the state changes(checkedValue: T[]) => void-
Option
typescript
interface Option {
label: string;
value: string;
disabled?: boolean;
}

Methods

Checkbox

NameDescriptionVersion
blur()Remove focus
focus()Get focus
nativeElementReturns the DOM node of the Checkbox5.17.3

Semantic DOM

Design Token

Global TokenHow to use?

FAQ

Why not work in Form.Item?

Form.Item default bind value to value property, but Checkbox value property is checked. You can use valuePropName to change bind property.

tsx
<Form.Item name="fieldA" valuePropName="checked">
<Checkbox />
</Form.Item>
Basic

Basic usage of checkbox.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Controlled Checkbox

Communicated with other components.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Check all

The indeterminate property can help you to achieve a 'check all' effect.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of Checkbox by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Disabled

Disabled checkbox.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Checkbox Group

Generate a group of checkboxes from an array.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Use with Grid

We can use Checkbox and Grid in Checkbox.Group, to implement complex layout.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon







  • root
    6.0.0
    Root element with inline-flex layout, baseline alignment, cursor style, reset styles and other basic checkbox container styles
  • icon
    6.0.0
    Checkbox icon element with size, direction, background, border, border-radius, transitions, and checked state checkmark styles
  • label
    6.0.0
    Label text element with padding and spacing styles relative to the checkbox