Components
Switch
Overview
Switch
is a React Native component designed for creating a switch or toggle control. It’s built on
top of React Native’s Switch. It can be customized with Tailwind
classes through the className
prop.
Preview
![](https://raw.githubusercontent.com/Mobilecn-UI/nativecn-ui/main/assets/examples/components/switch-light.png)
Light mode
![](https://raw.githubusercontent.com/Mobilecn-UI/nativecn-ui/main/assets/examples/components/switch-dark.png)
Dark mode
Installation
npx nativecn-ui add Switch
Properties
className?: string (optional)
- The classes for the switch.- See React Native’s Switch props
Usage
Basic Usage
Here’s how you can use the Switch
component:
const [isEnabled, setIsEnabled] = useState(false);
return <Switch onValueChange={setIsEnabled} value={isEnabled} />;