# rc-switch

> switch ui component for react

Latest version **4.1.0** (published 2023-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install rc-switch
pnpm add rc-switch
yarn add rc-switch
bun add rc-switch
```

## Health

**Score 45/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2023-04-23 |
| First published | 2015-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 196 |
| Maintainers | benjycui, yesmeck, afc163, yiminghe, valleykid, zombiej, madccc |
| Keywords | react, react-component, react-switch, switch |

## Links

- npm: https://www.npmjs.com/package/rc-switch
- Repository: https://github.com/react-component/switch
- Homepage: http://github.com/react-component/switch
- Issues: http://github.com/react-component/switch/issues
- npm.io page: https://npm.io/package/rc-switch

## Dependencies (3)

- [rc-util](https://npm.io/package/rc-util.md) ^5.30.0
- [classnames](https://npm.io/package/classnames.md) ^2.2.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.21.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2023-04-23
- 4.0.0-alpha.0 (alpha) — 2022-09-20
- 4.0.0 — 2022-09-20
- 1.9.2 — 2020-10-27
- 1.9.1 — 2020-10-27
- 3.2.2 — 2020-10-21
- 3.2.1 — 2020-08-24
- 3.2.0 — 2020-05-29
- 3.0.2 — 2020-05-19
- 3.1.0 — 2020-05-18
- 3.0.1 — 2020-05-18
- 3.0.0 — 2020-05-17
- 2.0.0 — 2020-05-08
- 1.9.0 — 2019-01-25
- 1.8.0 — 2018-09-12
- … 19 more at https://npm.io/package/rc-switch/versions

## README

# rc-switch

---

Switch ui component for react.

[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]
[![build status][github-actions-image]][github-actions-url]
[![Test coverage][codecov-image]][codecov-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]

[npm-image]: http://img.shields.io/npm/v/rc-switch.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-switch
[travis-image]: https://img.shields.io/travis/react-component/switch/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/switch
[github-actions-image]: https://github.com/react-component/switch/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/switch/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/switch/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/switch
[david-url]: https://david-dm.org/react-component/switch
[david-image]: https://david-dm.org/react-component/switch/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/switch?type=dev
[david-dev-image]: https://david-dm.org/react-component/switch/dev-status.svg?style=flat-square
[download-image]: https://img.shields.io/npm/dm/rc-switch.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-switch
[bundlephobia-url]: https://bundlephobia.com/package/rc-switch
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-switch

## Install

[![rc-switch](https://nodei.co/npm/rc-switch.png)](https://npmjs.org/package/rc-switch)

## Usage

```js
import Switch from 'rc-switch';

export default () => <Switch />;
```

## Compatibility

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| IE11, Edge                                                                                                                                                                                                     | last 2 versions                                                                                                                                                                                                  | last 2 versions                                                                                                                                                                                              | last 2 versions                                                                                                                                                                                              | last 2 versions                                                                                                                                                                                                      |

## API

| Property       | Type                     | Default   | Description                                              |
| -------------- | ------------------------ | --------- | -------------------------------------------------------- |
| prefixCls      | String                   | rc-switch |                                                          |
| className      | String                   | ''        | additional class name of root node                       |
| checked        | boolean                  | false     | whether switch is checked                                |
| defaultChecked | boolean                  | false     | whether switch is checked on init                        |
| onChange       | Function(checked, event) |           | called when switch is checked or unchecked               |
| tabIndex       | number                   |           | tab-index of switch node                                 |
| onClick        | Function(checked, event) |           | called when switch is clicked                            |
| autoFocus      | boolean                  |           | get focus when mounts                                    |
| disabled       | boolean                  | false     | whether switch is disabled                               |
| loadingIcon    | React.ReactNode          |           | specific the extra node. generally used in loading icon. |

## Development

```
npm install
npm start
```

Online demo: http://react-component.github.io/switch/

## License

rc-switch is released under the MIT license.

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