# @nghinv/react-native-switch

> React Native switch Library

Latest version **0.1.0** (published 2021-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nghinv/react-native-switch
pnpm add @nghinv/react-native-switch
yarn add @nghinv/react-native-switch
bun add @nghinv/react-native-switch
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-08-09 |
| First published | 2021-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 41.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | NghiNV |
| Maintainers | nghinv |
| Keywords | react-native, ios, android, switch, react-native-switch, component |

## Links

- npm: https://www.npmjs.com/package/@nghinv/react-native-switch
- Repository: https://github.com/nghinv-software/react-native-switch
- Homepage: https://github.com/nghinv-software/react-native-switch#readme
- Issues: https://github.com/nghinv-software/react-native-switch/issues
- npm.io page: https://npm.io/package/@nghinv/react-native-switch

## Dependencies (1)

- [react-fast-compare](https://npm.io/package/react-fast-compare.md) *

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-08-09
- 0.0.5 — 2021-07-31
- 0.0.4 — 2021-06-22
- 0.0.1 — 2021-06-22

## README

# @nghinv/react-native-switch

React Native Switch Library

---

[![CircleCI](https://circleci.com/gh/nghinv-software/react-native-switch.svg?style=svg)](https://circleci.com/gh/nghinv-software/react-native-switch)
[![Version][version-badge]][package]
[![MIT License][license-badge]][license]
[![All Contributors][all-contributors-badge]][all-contributors]
[![PRs Welcome][prs-welcome-badge]][prs-welcome]

<p align="center">
<img src="./assets/demo.png" width="300"/>
</p>

## Installation

```sh
yarn add @nghinv/react-native-switch
```

or 

```sh
npm install @nghinv/react-native-switch
```

- peerDependencies

```sh
yarn add react-native-gesture-handler react-native-reanimated
```

## Usage

```js
import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Switch from '@nghinv/react-native-switch';

function App() {
  const [enable, setEnable] = useState(true);

  return (
    <View style={styles.container}>
      <View style={styles.row}>
        <Text style={styles.title}>Switch</Text>
        <Switch 
          value={enable} 
          onChange={(value) => setEnable(value)} 
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  row: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    padding: 16,
  },
  title: {
    fontSize: 16,
  },
});

export default App;
```

# Property

| Property | Type | Default | Description |
|----------|:----:|:-------:|-------------|
| size | `Number` | `27` |  |
| thumbColor | `String` | `white` |  |
| trackColor | `TrackColorProperty` |  |  |
| disabled | `Bool` | `false` |  |
| value | `Bool` | `false` |  |
| onChange | `(value: boolean) => void` | `undefined` |  |
| style | `ViewStyle` | `undefined` |  |
| progress | `Animated.SharedValue<number>` | `undefined` |  |


## TrackColorProperty

| Property | Type | Default | Description |
|----------|:----:|:-------:|-------------|
| false | `String` | `rgba(120, 120, 120, 0.3)` |  |
| true | `String` | `#31D158` |  |

---
## Credits

- [@Nghi-NV](https://github.com/Nghi-NV)

[version-badge]: https://img.shields.io/npm/v/@nghinv/react-native-switch.svg?style=flat-square
[package]: https://www.npmjs.com/package/@nghinv/react-native-switch
[license-badge]: https://img.shields.io/npm/l/@nghinv/react-native-switch.svg?style=flat-square
[license]: https://opensource.org/licenses/MIT
[all-contributors-badge]: https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square
[all-contributors]: #contributors
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs-welcome]: http://makeapullrequest.com

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