# @hi-ui/checkbox

> A sub-package for @hi-ui/hiui.

Latest version **5.0.0** (published 2026-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hi-ui/checkbox
pnpm add @hi-ui/checkbox
yarn add @hi-ui/checkbox
bun add @hi-ui/checkbox
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-06-06 |
| First published | 2021-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 47.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 879 |
| Author | HiUI |
| Maintainers | sivan, solarjoker, lanzhi_lee, zhouyun |

## Links

- npm: https://www.npmjs.com/package/@hi-ui/checkbox
- Repository: https://github.com/XiaoMi/hiui
- Homepage: https://github.com/XiaoMi/hiui/tree/master/packages/ui/checkbox#readme
- Issues: https://github.com/XiaoMi/hiui/issues
- npm.io page: https://npm.io/package/@hi-ui/checkbox

## Dependencies (8)

- [@hi-ui/env](https://npm.io/package/@hi-ui/env.md) ^5.0.0
- [@hi-ui/classname](https://npm.io/package/@hi-ui/classname.md) ^5.0.0
- [@hi-ui/use-check](https://npm.io/package/@hi-ui/use-check.md) ^5.0.0
- [@hi-ui/use-latest](https://npm.io/package/@hi-ui/use-latest.md) ^5.0.0
- [@hi-ui/react-utils](https://npm.io/package/@hi-ui/react-utils.md) ^5.0.0
- [@hi-ui/type-assertion](https://npm.io/package/@hi-ui/type-assertion.md) ^5.0.0
- [@hi-ui/use-merge-semantic](https://npm.io/package/@hi-ui/use-merge-semantic.md) ^5.0.0
- [@hi-ui/use-uncontrolled-state](https://npm.io/package/@hi-ui/use-uncontrolled-state.md) ^5.0.0

## Recent versions

- 5.0.0 (latest) — 2026-06-06
- 5.0.0-rc.0 (rc) — 2026-06-02
- 5.0.0-experimental.1 (experimental) — 2026-03-08
- 5.0.0-canary.8 (canary) — 2026-03-08
- 5.0.0-alpha.0 (alpha) — 2025-09-29
- 4.0.0-beta.16 (feature) — 2022-07-13
- 5.0.0-experimental.0 — 2026-02-05
- 5.0.0-canary.7 — 2025-12-15
- 5.0.0-canary.6 — 2025-11-19
- 5.0.0-canary.5 — 2025-11-12
- 5.0.0-canary.4 — 2025-09-10
- 5.0.0-canary.3 — 2025-08-21
- 5.0.0-canary.2 — 2025-07-06
- 5.0.0-canary.1 — 2025-07-04
- 5.0.0-canary.0 — 2025-05-14
- … 62 more at https://npm.io/package/@hi-ui/checkbox/versions

## README

# Checkbox 复选

复选是用来在一组平铺选项中同时选择 1 个以上的选项

## 何时使用

需要快速完成多选一且备选项数量不多时

常见于后台设置、调研问卷、表单等场景

## 使用示例

<!-- Inject Stories -->

## Props

### Checkbox

| 参数           | 说明             | 类型    | 可选值        | 默认值 |
| -------------- | ---------------- | ------- | ------------- | ------ |
| autoFocus      | 是否自动获取焦点 | boolean | true \| false | false  |
| checked        | 是否选中         | boolean | true \| false | false  |
| defaultChecked | 是否默认选中     | boolean | true \| false | false  |
| disabled       | 是否禁用         | boolean | true \| false | false  |
| indeterminate  | 不全选的样式控制 | boolean | true \| false | false  |

### Checkbox.Group

| 参数         | 说明                                                         | 类型                               | 可选值                     | 默认值       |
| ------------ | ------------------------------------------------------------ | ---------------------------------- | -------------------------- | ------------ |
| placement    | 排列方式                                                     | string                             | 'horizontal' \| 'vertical' | 'horizontal' |
| data         | 指定可选项                                                   | ReactText[] \| DataItem[]          | -                          | []           |
| defaultValue | 默认选中的项                                                 | ReactText[]                        | -                          | []           |
| disabled     | 是否禁用                                                     | boolean                            | true \| false              | false        |
| name         | `CheckboxGroup` 下所有 `input[type="checkbox"]` 的 name 属性 | string                             | -                          | -            |
| onChange     | 变化时的回调                                                 | (checkedList: ReactText[]) => void | -                          | -            |
| value        | 指定选中的项                                                 | ReactText[]                        | -                          | -            |

## Events

### Checkbox

| 名称     | 说明         | 类型                                                   | 参数                  | 返回值 |
| -------- | ------------ | ------------------------------------------------------ | --------------------- | ------ |
| onChange | 变化时的回调 | (event: React.ChangeEvent\<HTMLInputElement\>) => void | event: input 事件对象 | -      |

### Checkbox.Group

| 名称     | 说明         | 类型                              | 参数                       | 返回值 |
| -------- | ------------ | --------------------------------- | -------------------------- | ------ |
| onChange | 变化时的回调 | (checkedIds: ReactText[]) => void | checkedIds: 选中项 ID 集合 | -      |

## Type

### DataItem

| 参数     | 说明            | 类型      |
| -------- | --------------- | --------- |
| id       | 选项唯一标识 id | ReactText |
| title    | 选项显示内容    | ReactNode |
| disabled | 是否禁用该选项  | boolean   |

## CHANGELOG

| 参数     | 变更类型                        | 变更内容                                                | 解决的问题                                 |
| -------- | ------------------------------- | ------------------------------------------------------- | ------------------------------------------ |
| propName | feature \| deprecated \| update | 变更了什么                                              | 之前是什么样子，解决什么问题               |
| ----     | ----                            | ----                                                    | ----                                       |
| children | feature                         | CheckboxGroup 支持内嵌 Checkbox                         | 实现灵活的布局                             |
| data     | deprecated                      | 只支持 DataItem[] 模型数据                              | 1. 规范统一；2. ReactText[] 用法接受度不高 |
| title    | feature                         | 1. 字段：content -> title; 2. 类型：string -> ReactNode | 1. 强化类型支持                            |

---
_Source: https://npm.io/package/@hi-ui/checkbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
