Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Toggle Switch React Native Component works on both iOS and Android

License

NotificationsYou must be signed in to change notification settings

aminebenkeroum/toggle-switch-react-native

Repository files navigation

Toggle Switch Component for react native, it works on Android, iOS and Web (react-native-web).

Buy Me A Coffee

Content

Installation

    1. Runnpm i toggle-switch-react-native --save
    1. import ToggleSwitch from 'toggle-switch-react-native'

Demo

Screenshots

Getting started

To Get Started, Importtoggle-switch-react-native to your js file.

import ToggleSwitch from 'toggle-switch-react-native'

Inside your component's render method, or any other method returning views, use ToggleSwitch:

<ToggleSwitchisOn={false}onColor="green"offColor="red"label="Example label"labelStyle={{color:"black",fontWeight:"900"}}size="large"onToggle={isOn=>console.log("changed to : ",isOn)}/>

API

PropsTypeOptionalDefaultDescription
isOnBooleantrue'false'Default state, true for On, false for off
onColorStringtrue'#634fc9'On Color
offColorStringtrue'#ecf0f1'Off Color
labelStringtrueCustom Label Text on the Left of the toggle Button
labelStyleObject, StyleSheettrue{marginHorizontal: 10}Custom Styling for the Label Text View
thumbOnStyleObject, StyleSheettruenullCustom Styling for the On Thumb
thumbOffStyleObject, StyleSheettruenullCustom Styling for the Off Thumb
trackOnStyleObject, StyleSheettruenullCustom Styling for the On Track
trackOffStyleObject, StyleSheettruenullCustom Styling for the Off Track
sizeStringtrue'medium'Size of the toggle switch button ( 'large', 'medium', 'small')
iconReact ComponenttruenullIcon for the toggle. Can be any React Component considerate of size
onToggleFunction CallbackfalsenoneCallback when the toggle switch component changes the state, params: isOn
disabledBooleantrue'false'Disable toggling the component
animationSpeedNumbertrue300Speed of the toggle animation

Contribution

If you encountered an Issue, please add a screenshot of the bug or a code snippet.

Quickest way to solve issue is to reproduce it on the example project

Pull requests are welcome. If you want to change the API or imporove something, feel free to create an issue and discuss it first.


MIT Licensed

About

Toggle Switch React Native Component works on both iOS and Android

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors12


[8]ページ先頭

©2009-2025 Movatter.jp