components/checkbox/index.en-US.md
<code src="./demo/basic.tsx">Basic</code> <code src="./demo/disabled.tsx">Disabled</code> <code src="./demo/controller.tsx">Controlled Checkbox</code> <code src="./demo/group.tsx">Checkbox Group</code> <code src="./demo/check-all.tsx">Check all</code> <code src="./demo/layout.tsx">Use with Grid</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code> <code src="./demo/debug-line.tsx" debug>Same line</code> <code src="./demo/debug-disable-popover.tsx" debug>Disabled to show Tooltip</code> <code src="./demo/debug-group-width.tsx" debug>Group same width</code> <code src="./demo/custom-line-width.tsx" debug>customize lineWidth</code>
Common props ref:Common props
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| checked | Specifies whether the checkbox is selected | boolean | false | |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | |
| defaultChecked | Specifies the initial state: whether or not the checkbox is selected | boolean | false | |
| disabled | If disable checkbox | boolean | false | |
| indeterminate | The indeterminate checked state of checkbox | boolean | false | |
| onChange | The callback function that is triggered when the state changes | (e: CheckboxChangeEvent) => void | - | |
| onBlur | Called when leaving the component | function() | - | |
| onFocus | Called when entering the component | function() | - | |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - |
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| defaultValue | Default selected value | (string | number)[] | [] | |
| disabled | If disable all checkboxes | boolean | false | |
| name | The name property of all input[type="checkbox"] children | string | - | |
| options | Specifies options | string[] | number[] | Option[] | [] | |
| value | Used for setting the currently selected value | (string | number | boolean)[] | [] | |
| title | title of the option | string | - | |
| className | className of the option | string | - | 5.25.0 |
| style | styles of the option | React.CSSProperties | - | |
| onChange | The callback function that is triggered when the state changes | (checkedValue: T[]) => void | - |
interface Option {
label: string;
value: string;
disabled?: boolean;
}
| Name | Description | Version |
|---|---|---|
| blur() | Remove focus | |
| focus() | Get focus | |
| nativeElement | Returns the DOM node of the Checkbox | 5.17.3 |
<code src="./demo/_semantic.tsx" simplify="true"></code>
<ComponentTokenTable component="Checkbox"></ComponentTokenTable>
Form.Item default bind value to value property, but Checkbox value property is checked. You can use valuePropName to change bind property.
<Form.Item name="fieldA" valuePropName="checked">
<Checkbox />
</Form.Item>