Switch | NativeBase | Universal Components for React and React Native

Search
K
Hire us
Resources
Data Display
Typography
Disclosure
Media and Icons
Others
If you are starting a new project, please try gluestack-ui for better performance and new design.
Switch
The Switch provides an alternative to the Checkbox component. It also allows a user to switch between enabled or disabled states.
Show Code
Playground
Examples
Basic
Playground
Sizes
Playground
Track & Thumb Color
Playground
Color Schemes
Playground
Props
size
The size (width and height) of the switch.
Type: ResponsiveValue<number | "full" | "sm" | "6" | "2xs" | "8" | "xs" | "12" | "md" | "16" | "xl" | "24" | "32" | "2" | "0.5" | "4" | "3" | "lg" | "1" | "2xl" | "10" | "20" | "64" | "0" | "px" | (string & {}) | ... 28 more ... | "5/6">
Default: md
isDisabled
If true, set the disabled to the invalid state.
Type: boolean
isHovered
If true, set the hovered state.
Type: boolean
name
The input name of the Switch when used in a form.
Type: string
onToggle
Function called when the state of the Switch changes.
Type: () => any
isChecked
If true, set the Switch to the checked state.
Type: boolean
defaultIsChecked
If true, the checkbox will be initially checked.
Type: boolean
isInvalid
If true, set the switch to the invalid state.
Type: boolean
onTrackColor
The track color of the Switch when on.
Type: ResponsiveValue<"gray.300" | "primary.500" | "gray.500" | (string & {}) | "contrastThreshold" | "white" | "black" | "lightText" | "darkText" | "primary.50" | "primary.100" | "primary.200" | ... 333 more ... | "tertiary.900">
offTrackColor
The track color of the Switch when off.
Type: ResponsiveValue<"gray.300" | "primary.500" | "gray.500" | (string & {}) | "contrastThreshold" | "white" | "black" | "lightText" | "darkText" | "primary.50" | "primary.100" | "primary.200" | ... 333 more ... | "tertiary.900">
onThumbColor
The thumb color of the Switch when on.
Type: ResponsiveValue<"gray.300" | "primary.500" | "gray.500" | (string & {}) | "contrastThreshold" | "white" | "black" | "lightText" | "darkText" | "primary.50" | "primary.100" | "primary.200" | ... 333 more ... | "tertiary.900">
offThumbColor
The thumb color of the Switch when off.
Type: ResponsiveValue<"gray.300" | "primary.500" | "gray.500" | (string & {}) | "contrastThreshold" | "white" | "black" | "lightText" | "darkText" | "primary.50" | "primary.100" | "primary.200" | ... 333 more ... | "tertiary.900">
colorScheme
Color scheme to be used for the Switch
Type: string
_hover
Props when Switch is hovered. Accepts all the Switch props.
Type: Omit<InterfaceSwitchProps, "_hover">
Accessibility
On mobile, uses native switch which is fully accessible.
On web, it uses checkbox with a set to switch.
Keyboard Interactions
Name
Description
Space
Toggles the component's state.
Nativebase logo
MadeWithNativeBase
Gluestack logo
gluestack-ui