Skip to content

Commit 2aa54df

Browse files
committed
docs: add Chinese README
1 parent e7e300e commit 2aa54df

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
</p>
1414
</div>
1515

16+
<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>
17+
1618

1719
## Highlights
1820

README.zh-CN.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<div align="center">
2+
<h1>@rc-component/switch</h1>
3+
<p><sub>Ant Design 生态的一部分。</sub></p>
4+
<p>🔀 React 开关组件。</p>
5+
6+
<p>
7+
<a href="https://www.npmjs.com/package/@rc-component/switch"><img src="https://img.shields.io/npm/v/@rc-component/switch.svg?style=flat-square" alt="npm version" /></a>
8+
<a href="https://www.npmjs.com/package/@rc-component/switch"><img src="https://img.shields.io/npm/dm/@rc-component/switch.svg?style=flat-square" alt="npm downloads" /></a>
9+
<a href="https://github.com/react-component/switch/actions"><img src="https://github.com/react-component/switch/actions/workflows/react-component-ci.yml/badge.svg" alt="CI" /></a>
10+
<a href="https://codecov.io/gh/react-component/switch"><img src="https://img.shields.io/codecov/c/github/react-component/switch/master.svg?style=flat-square" alt="Codecov" /></a>
11+
<a href="https://bundlephobia.com/package/@rc-component/switch"><img src="https://badgen.net/bundlephobia/minzip/@rc-component/switch" alt="bundle size" /></a>
12+
<a href="https://github.com/umijs/dumi"><img src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square" alt="dumi" /></a>
13+
</p>
14+
</div>
15+
16+
<p align="center"><a href="./README.md">English</a> | 简体中文</p>
17+
18+
19+
## 特性
20+
21+
- Renders a native button with `role="switch"` and `aria-checked` state.
22+
- 支持 controlled and uncontrolled checked state.
23+
- Handles click and keyboard toggles with left and right arrow keys.
24+
- 提供 content class/style slots for checked and unchecked labels.
25+
26+
## 安装
27+
28+
```bash
29+
npm install @rc-component/switch
30+
```
31+
32+
## 使用
33+
34+
```tsx pure
35+
import Switch from '@rc-component/switch';
36+
import '@rc-component/switch/assets/index.css';
37+
38+
export default () => <Switch checkedChildren="On" unCheckedChildren="Off" />;
39+
```
40+
41+
Online preview: https://switch.react-component.vercel.app/
42+
43+
## API
44+
45+
| 名称 | 类型 | 默认值 | 说明 |
46+
| ------------------- | ----------------------------------- | ------------- | ------------------------------------------ |
47+
| `autoFocus` | boolean | - | Focus the switch on mount. |
48+
| `checked` | boolean | - | Controlled checked state. |
49+
| `checkedChildren` | React.ReactNode | - | Content shown when checked. |
50+
| `className` | string | - | Additional class name. |
51+
| `classNames` | `{ content?: string }` | - | Semantic class names for internal content. |
52+
| `defaultChecked` | boolean | false | Initial checked state. |
53+
| `disabled` | boolean | false | Disable interaction. |
54+
| `loadingIcon` | React.ReactNode | - | Extra loading icon node. |
55+
| `onChange` | `(checked, event) => void` | - | Triggered after checked state changes. |
56+
| `onClick` | `(checked, event) => void` | - | Triggered after click. |
57+
| `onKeyDown` | React.KeyboardEventHandler | - | Key down handler. |
58+
| `prefixCls` | string | `'rc-switch'` | Prefix class name. |
59+
| `style` | React.CSSProperties | - | Root style. |
60+
| `styles` | `{ content?: React.CSSProperties }` | - | Semantic styles for internal content. |
61+
| `tabIndex` | number | - | Tab index. |
62+
| `title` | string | - | Native title attribute. |
63+
| `unCheckedChildren` | React.ReactNode | - | Content shown when unchecked. |
64+
65+
## 本地开发
66+
67+
```bash
68+
npm install
69+
npm start
70+
npm test
71+
npm run tsc
72+
npm run compile
73+
npm run build
74+
```
75+
76+
## 发布
77+
78+
```bash
79+
npm run prepublishOnly
80+
```
81+
82+
The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.
83+
84+
## 许可证
85+
86+
@rc-component/switch is released under the [MIT](./LICENSE.md) license.

0 commit comments

Comments
 (0)