Skip to main content

Switch

Switch

Switches are a useful way to change the state of functionalities and preferences in a system. They work by controlling two options that are mutually exclusive, meaning only one of them can be selected at a time. And they always have a default state, such as on/off or true/false.

Examples

Basic Switch

Basic Switch

Selector Switch

Switch.Selector
My Dashboard

Switch Props

Prop
Required
Default
Type

checked

false

boolean

disabled

false

boolean

onPress

() => void

style

StyleProp<ViewStyle>

testID

string

Switch.Selector Props

Prop
Required
Default
Type

options

required

[OptionType<T>, OptionType<T>]

value

required

T

onPress

(value: T) => void

style

StyleProp<ViewStyle>

testID

string