# @rn-components-kit/switch

> Switching selector.

Latest version **1.0.1** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rn-components-kit/switch
pnpm add @rn-components-kit/switch
yarn add @rn-components-kit/switch
bun add @rn-components-kit/switch
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-25 |
| First published | 2019-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 76 |
| Author | SmallStoneSK |
| Maintainers | smallstonesk |
| Keywords | react-native, reactnative, reactjs, UI kit, switch |

## Links

- npm: https://www.npmjs.com/package/@rn-components-kit/switch
- Repository: https://github.com/SmallStoneSK/rn-components-kit
- Homepage: https://github.com/SmallStoneSK/rn-components-kit#readme
- Issues: https://github.com/SmallStoneSK/rn-components-kit/issues
- npm.io page: https://npm.io/package/@rn-components-kit/switch

## Recent versions

- 1.0.1 (latest) — 2019-06-25
- 1.0.0 — 2019-05-21

## README

# Switch

[![NPM version](https://img.shields.io/npm/v/@rn-components-kit/switch.svg)](https://www.npmjs.com/package/@rn-components-kit/switch)

English | [中文](./README.zh-CN.md)

Switching selector. It supports the following features:

- customize color
- customize size
- two types: `cupertino` and `material`

## How to use

```bash
npm install @rn-components-kit/switch --save
```

|Preview|Code|
|------------|:---------:|
|<img width="375" src="./preview/various-sizes-switch.png"/>|[Demo1 Code](./demos/Demo1.js)|
|<img width="375" src="./preview/various-colors-switch.png"/>|[Demo2 Code](./demos/Demo2.js)|
|<img width="375" src="./preview/cupertino-vs-material-switch.png"/>|[Demo3 Code](./demos/Demo3.js)|
|<img width="375" src="./preview/enabled-vs-disabled-switch.gif"/>|[Demo4 Code](./demos/Demo4.js)|
|<img width="375" src="./preview/switch-value-change-callback.gif"/>|[Demo5 Code](./demos/Demo5.js)|

## Props

- [`style`](#style)
- [`type`](#type)
- [`value`](#value)
- [`disabled`](#disabled)
- [`width`](#width)
- [`height`](#height)
- [`thumbRadius`](#thumbRadius)
- [`thumbColor`](#thumbColor)
- [`trackOnColor`](#trackOnColor)
- [`trackOffColor`](#trackOffColor)
- [`onValueChange`](#onValueChange)

## Reference

### Props

#### `style`

Allows you to customize style

|Type|Required|Default|
|----|--------|-------|
|object|no|-|

#### `type`

Two types (`cupertino` for IOS and `material` for Android)

|Type|Required|Default|
|----|--------|-------|
|enum(`'cupertino'`, `'material'`)|no|'cupertino'|

#### `value`

Determines whether switch is on when initial rendering

|Type|Required|Default|
|----|--------|-------|
|boolean|no|false|

#### `disabled`

Determines whether switch is touchabled

|Type|Required|Default|
|----|--------|-------|
|boolean|no|false|

#### `width`

Width of switch

|Type|Required|Default|
|----|--------|-------|
|number|no|40|

#### `height`

Height of switch's track

|Type|Required|Default|
|----|--------|-------|
|number|no|20|

#### `thumbRadius`

Radius of thumb

|Type|Required|Default|
|----|--------|-------|
|number|no|8|

#### `thumbColor`

Color of thumb

|Type|Required|Default|
|----|--------|-------|
|string|no|'#FFF'|

#### `trackOnColor`

Color of track when switch is "on" status

|Type|Required|Default|
|----|--------|-------|
|string|no|'#79D472'|

#### `trackOffColor`

Color of track when switch is "off" status

|Type|Required|Default|
|----|--------|-------|
|string|no|'#CCC'|

#### `onValueChange`

```js
(value: boolean) => void
```

A callback will be triggered when switch's status changes

|Type|Required|Default|
|----|--------|-------|
|function|no|() => {}|

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