react-native-toggle-button
Version:
Cool and easy to use react native toggle button
93 lines (63 loc) • 3.95 kB
Markdown
<img alt="React Native Toggle Button" src="assets/logo.png" width="1050"/>
[](https://github.com/WrathChaos/react-native-toggle-button)
[](https://www.npmjs.com/package/react-native-toggle-button)
[](https://www.npmjs.com/package/react-native-toggle-button)

[](https://opensource.org/licenses/MIT)
[](https://github.com/prettier/prettier)
<p align="center">
<img alt="React Native Toggle Button"
src="assets/Screenshots/typescript.jpg" />
</p>
Add the dependency:
```bash
npm i react-native-toggle-button
```
Zero Dependency
```jsx
import ToggleButton from "react-native-toggle-button";
```
```jsx
<ToggleButton
primaryText="On"
secondaryText="Off"
onPress={(isToggled: boolean) => {
console.log(isToggled);
}}
/>
```
You can checkout the example project 🥰
Simply run
- `npm i`
- `react-native run-ios/android`
should work of the example project.
| Property | Type | Default | Description |
| ------------- | :------: | :-------: | ------------------------------------------------------------------ |
| primaryText | string | undefined | change the primaryText |
| secondaryText | string | undefined | change the secondaryText |
| onPress | function | undefined | set your own logic for the button functionality when it is pressed |
| Property | Type | Default | Description |
| ------------------- | :----------------------: | :-----: | ----------------------------------------------------------------------------------------- |
| inial | boolean | true | let you change the initial toggled value |
| style | ViewStyle | default | set or override the style object for the main container |
| activeButtonStyle | ViewStyle | default | set or override the style object for the `active button` style |
| inactiveButtonStyle | ViewStyle | default | set or override the style object for the `inactive button` style |
| activeTextStyle | TextStyle | default | set or override the style object for the `active text` style |
| inactiveTextStyle | TextStyle | default | set or override the style object for the `inactive text` style |
| TouchableComponent | TouchableWithoutFeedback | default | set your own component instead of default react-native TouchableWithoutFeedback component |
- [x] ~~LICENSE~~
- [ ] Write an article about the lib on Medium
FreakyCoder, kurayogun@gmail.com
React Native Toggle Button is available under the MIT license. See the LICENSE file for more info.