# bee-switch

> switch ui component for react

Latest version **2.0.7** (published 2020-04-24) · MIT license · 739 weekly downloads

## Install

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

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: no vulnerabilities; growing popularity.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2020-04-24 |
| First published | 2016-11-03 |
| Weekly downloads | 739 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 3 |
| Unpacked size | 28.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | ahua52, banyudu, bjyxszd, boyuzhou, guoyongfeng, huayingjie, jonyw, kvkens, liushaozhen, liuyk, npm_yx, supernever, tinper-bot, whizbz, yangchch, yonyoufed, zhaoyuchief |
| Keywords | react, react-component, react-switch, iuap-design, neoui-react, switch |

## Links

- npm: https://www.npmjs.com/package/bee-switch
- Repository: https://github.com/tinper-bee/switch
- Issues: https://github.com/tinper-bee/switch/issues
- npm.io page: https://npm.io/package/bee-switch

## Dependencies (3)

- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.20.0
- [tinper-bee-core](https://npm.io/package/tinper-bee-core.md) latest

## 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

- 2.0.7 (latest) — 2020-04-24
- 2.0.5 (beta) — 2019-05-15
- 2.0.5-alpha.1 (alpha) — 2019-05-15
- 2.0.6 — 2019-08-06
- 2.0.6-alpha.0 — 2019-08-06
- 2.0.5-alpha.0 — 2019-05-15
- 2.0.4 — 2019-04-23
- 2.0.3 — 2019-04-02
- 2.0.2 — 2019-02-28
- 2.0.1 — 2019-01-23
- 2.0.0 — 2019-01-22
- 1.0.4 — 2018-01-16
- 1.0.3 — 2017-11-14
- 1.0.2 — 2017-11-03
- 1.0.1 — 2017-10-19
- … 8 more at https://npm.io/package/bee-switch/versions

## README

# bee-switch

[![npm version](https://img.shields.io/npm/v/bee-switch.svg)](https://www.npmjs.com/package/bee-switch)
[![Build Status](https://img.shields.io/travis/tinper-bee/bee-switch/master.svg)](https://travis-ci.org/tinper-bee/bee-switch)
[![Coverage Status](https://coveralls.io/repos/github/tinper-bee/bee-switch/badge.svg?branch=master)](https://coveralls.io/github/tinper-bee/bee-switch?branch=master)
[![dependencies Status](https://david-dm.org/tinper-bee/bee-switch/status.svg)](https://david-dm.org/tinper-bee/bee-switch)
[![NPM downloads](http://img.shields.io/npm/dm/bee-switch.svg?style=flat)](https://npmjs.org/package/bee-switch)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/tinper-bee/bee-switch.svg)](http://isitmaintained.com/project/tinper-bee/bee-switch "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/tinper-bee/bee-switch.svg)](http://isitmaintained.com/project/tinper-bee/bee-switch "Percentage of issues still open")


两种状态切换的开关



## 使用

### 使用单独的switch包
#### 组件引入
先进行下载switch包
```
npm install --save bee-switch
```
组件调用
```js
import { Switch } from 'bee-switch';
React.render(<div>
            <Switch />
        </div>, document.getElementById('target'));
```
#### 样式引入

- 可以使用link引入dist目录下switch.css
```
<link rel="stylesheet" href="./node_modules/build/bee-switch.css">
```
- 可以在js中import样式
```js
import "./node_modules/src/Switch.scss"
//或是
import "./node_modules/build/bee-switch.css"
```



### API

|参数|说明|类型|默认值|
|:---|:----|:---|:------|
|checked	|指定当前是否选中|	Boolean	|false|
|defaultChecked	|初始是否选中	|Boolean|	false |
|onChange	|变化时回调函数,自定义参照demo	|Function(checked:Boolean) |
|disabled|设置是否禁用|Boolean|false|
|checkedChildren	|选中时的内容	|React| Node |
|unCheckedChildren	|非选中时的内容	|React| Node|
|size|	大小设置，oneOf：`sm`, `lg`|string|''|
|colors| 颜色设置，oneOf：`primary`,`success`,`info`,`dark`,`warning`|	string	|''|
|onKeyDown| 键盘回调 |	Function	| - |
|enterKeyDown| 是否启用 enter 和 space 键 | Boolean | true |

#### setup develop environment

```sh
$ git clone https://github.com/tinper-bee/bee-switch
$ cd bee-switch
$ npm install
$ npm run dev
```

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