GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — Switch | NativeBase | Universal Components for React and React Native

Switch | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
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
const Example = () => {
return <Switch size="lg" />;
};
Examples
Basic
Playground
const Example = () => {
return <HStack alignItems="center" space={4}>
<Text>Bluetooth</Text>
<Switch size="sm" />
</HStack>;
};
Sizes
Playground
const Example = () => {
return <VStack space={4} alignItems="center">
<Switch size="sm" />
<Switch size="md" />
<Switch size="lg" />
</VStack>;
};
Track & Thumb Color
Playground
const Example = () => {
return <VStack space={4} alignItems="center">
<Switch />
<Switch offTrackColor="orange.100" onTrackColor="orange.200" onThumbColor="orange.500" offThumbColor="orange.50" />
<Switch offTrackColor="indigo.100" onTrackColor="indigo.200" onThumbColor="indigo.500" offThumbColor="indigo.50" />
</VStack>;
};
Color Schemes
Playground
const Example = () => {
return <VStack space={4} alignItems="center">
<Switch defaultIsChecked colorScheme="primary" />
<Switch defaultIsChecked colorScheme="secondary" />
<Switch defaultIsChecked colorScheme="emerald" />
</VStack>;
};
Props
Switch implements
Switch from React Native
,
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
size
The size (width and height) of the switch.
Type: ThemeComponentSizeType<"Switch">
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: (...args: any) => void
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" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
offTrackColor
The track color of the Switch when off.
Type: ResponsiveValue<"gray.300" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
onThumbColor
The thumb color of the Switch when on.
Type: ResponsiveValue<"gray.300" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
offThumbColor
The thumb color of the Switch when off.
Type: ResponsiveValue<"gray.300" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
colorScheme
Color scheme to be used for the Switch
Type: ColorSchemeType
_hover
Props when Switch is hovered. Accepts all the Switch props.
Type: Omit<Partial<ISwitchProps>, "_hover">
Accessibility
On mobile, uses native switch which is fully accessible.
On web, it uses checkbox with a
role
set to switch.
Keyboard Interactions
Name
Description
Space
Toggles the component's state.
Previous
Slider
Next
TextArea
Quick Nav
Examples
Basic
Sizes
Track & Thumb Color
Color Schemes
Props
Accessibility
Keyboard Interactions
MadeWithNativeBase
gluestack-ui
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.