Switch

Switch component gives an option to the user to toggle between two option to either pick one of the value base the switch value,this can be helpful when you are giving the user an option to choose between any two option.

NumberPad
NumberPad

Usage

<Switch
isOn={isOn}
onColor="#00D09C"
offColor="#E6E7E8"
// label="Example label"
// size="small"
onToggle={onThemeSwitch}
/>

Props

isOn

A boolean value to keep track whether the switch value is active or deactive.

TypeDefaultRequired
boolean falseYes

onColor

color which you want to have as switch component's background when its ON

TypeDefaultRequired
string #00D09CNo

offColor

color which you want to have as switch component's background when its OFF

TypeDefaultRequired
string #EBEBF5No

onToggle

callback function that will be called to set isOn in your Parent component's state to control you ui with it.

TypeDefaultRequired
function NoneYes

size

you can set this props to control your dimension of switch

TypeDefaultRequired
enum('sm', 'md', 'lg') mdNo

icon

You can pass custom icon for switch to make the ui more impressive,like if you are having light mode and dark mode then you can pass sunlight and moonlight icon into switch to make you switch to look much more good. you can use react-native-vector-icons to send ON & OFF icons

TypeDefaultRequired
ReactNode NoneNo

disabled

boolean to disable click event on the switch

TypeDefaultRequired
boolean falseNo