Files
2026-10-18 15:42:33 +08:00

58 lines
1.3 KiB
Plaintext

# Checkbox
A control that allows the user to toggle between checked and not checked.
<WidgetExample name="checkbox-basic" />
## Use cases
- **Suitable**: A single binary choice (accepting terms, a subscription toggle)
- **Suitable**: Checkable items in a form
- **Not suitable**: Mutually exclusive choices (use `radio-group`)
## Usage
```tsx
import { Checkbox } from "@lcui/react"
```
```tsx
<Checkbox />
```
Use `checked` to control the checked state; a `change` event is emitted when it changes.
## Examples
### Description
Pair `FieldContent` and `FieldDescription` to add helper text to the option.
<WidgetExample name="checkbox-description" />
### Group
Combine several `Field`s to build a checkbox list.
<WidgetExample name="checkbox-group" />
### Indeterminate
`indeterminate` expresses the "some children are selected" visual state, showing a minus icon.
<WidgetExample name="checkbox-indeterminate" />
### Disabled
<WidgetExample name="checkbox-disabled" />
## Caveats
:::caution
**Indeterminate is a state, not a default.** The indeterminate state (`indeterminate="true"`) expresses the "some children are selected" visual state (for example, a parent checkbox when only some children are checked). Clicking an indeterminate checkbox transitions it to the checked state.
:::
## API Reference
<FieldTable name="checkbox" />