# @hi-ui/radio

> 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/radio
pnpm add @hi-ui/radio
yarn add @hi-ui/radio
bun add @hi-ui/radio
```

## 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-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 62.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/radio
- Repository: https://github.com/XiaoMi/hiui
- Homepage: https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
- Issues: https://github.com/XiaoMi/hiui/issues
- npm.io page: https://npm.io/package/@hi-ui/radio

## Dependencies (7)

- [@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/dom-utils](https://npm.io/package/@hi-ui/dom-utils.md) ^5.0.0
- [@hi-ui/func-utils](https://npm.io/package/@hi-ui/func-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.9 (canary) — 2026-03-08
- 5.0.0-alpha.0 (alpha) — 2025-09-29
- 4.0.0-beta.20 (feature) — 2022-07-13
- 5.0.0-experimental.0 — 2026-02-05
- 5.0.0-canary.8 — 2025-12-15
- 5.0.0-canary.7 — 2025-12-03
- 5.0.0-canary.6 — 2025-11-19
- 5.0.0-canary.5 — 2025-11-12
- 5.0.0-canary.4 — 2025-08-21
- 5.0.0-canary.3 — 2025-08-06
- 5.0.0-canary.2 — 2025-07-06
- 5.0.0-canary.1 — 2025-07-04
- … 52 more at https://npm.io/package/@hi-ui/radio/versions

## README

# Radio 单选

单选是用来在一组平铺选项中选择目标选项，每次只选一个

## 何时使用

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

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

## 使用示例

<!-- Inject Stories -->

## Props

### Radio.Group

| 参数         | 说明                                         | 类型             | 可选值                     | 默认值       |
| ------------ | -------------------------------------------- | ---------------- | -------------------------- | ------------ |
| data         | 选择项数据源                                 | DataItem[]       | -                          | -            |
| placement    | 设置水平或垂直展示                           | string           | 'vertical' \| 'horizontal' | 'horizontal' |
| value        | 选中项的值（受控）                           | string \| number | -                          | -            |
| defaultValue | 默认选中项的值                               | string \| number | -                          | -            |
| disabled     | 是否禁用                                     | boolean          | -                          | -            |
| type         | 单选按展示形状                               | string           | 'default' \| 'button'      | 'default'    |
| name         | `RadioGroup` 下透传给所有 Radio 的 name 属性 | string           | -                          | -            |

### Radio

| 参数           | 说明             | 类型    | 可选值        | 默认值 |
| -------------- | ---------------- | ------- | ------------- | ------ |
| value          | 单选对应的值     | string  | -             | -      |
| autoFocus      | 是否自动获取焦点 | boolean | true \| false | false  |
| disabled       | 是否禁用         | boolean | -             | -      |
| checked        | 是否选中         | boolean | true \| false | false  |
| defaultChecked | 是否默认选中     | boolean | true \| false | false  |
| readOnly       | 是否只读         | boolean | true \| false | false  |

## Events

### Radio

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

### RadioGroup

| 名称     | 说明               | 类型                    | 参数             | 返回值 |
| -------- | ------------------ | ----------------------- | ---------------- | ------ |
| onChange | 选中项改变时的回调 | (value: string) => void | value: 选中项 ID | -      |

## Type

### DataItem

| 参数     | 说明             | 类型      | 可选值        | 默认值 |
| -------- | ---------------- | --------- | ------------- | ------ |
| id       | 选择项对应的值   | string    | -             | -      |
| content  | 选择项的展示内容 | ReactText | -             | -      |
| disabled | 是否禁用         | boolean   | true \| false | false  |

## CHANGELOG

| 参数     | 变更类型                        | 变更内容                  | 解决的问题                   |
| -------- | ------------------------------- | ------------------------- | ---------------------------- |
| propName | feature \| deprecated \| update | 变更了什么                | 之前是什么样子，解决什么问题 |
| ----     | ----                            | ----                      | ----                         |
| children | feature                         | RadioGroup 支持内嵌 Radio | 实现灵活的布局               |
| content  | feature                         | 类型：string -> ReactNode | 1. 强化类型支持              |
| readOnly | feature                         | -                         | 1. 强化 Radio 功能支持       |

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