Switch
Switch component for toggling boolean value related to some context
(code example)
Usageβ
Live Editor
function Example(props) { const [value, setValue] = useState(false); return ( <div> <Switch value={value} onValueChange={setValue}/> </div> ); }
Result
Loading...
APIβ
disabledβ
Whether the switch should be disabled
boolean
disabledColorβ
The Switch background color when it's disabled
string
heightβ
The Switch height
number
idβ
Component id
string
offColorβ
The Switch background color when it's turned off
string
onColorβ
The Switch background color when it's turned on
string
onValueChangeβ
Invoked with the new value when the value changes
(value: boolean) => void
styleβ
Custom style
ViewStyle
testIDβ
Component test id
string
thumbColorβ
The Switch's thumb color
string
thumbSizeβ
The Switch's thumb size (width & height)
number
thumbStyleβ
The Switch's thumb style
ViewStyle
valueβ
The value of the switch. If true the switch will be turned on. Default value is false
boolean
widthβ
The Switch width
number