Switch
Switch is a visual toggle between two mutually exclusive states — on and off.
How to use
import React from 'react';
import {Switch} from '@gyri/native-ui-components';
const MyComponent = () => {
const [isSwitchOn, setIsSwitchOn] = React.useState(false);
const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn);
return <Switch
style={style}
className={className}
value={isSwitchOn}
onValueChange={onToggleSwitch}
trackColor={{false: 'black', true: 'white'}}
thumbColor={isDarkThemeEnabled ? 'black' : 'white'}
/>;
};
export default MyComponent;
Props
| # | Name | Data type | Default value | Values | Description |
|---|---|---|---|---|---|
| 1 | style | object | Custom style object | ||
| 2 | className | string | '' | It defined nativewind style classes. |
For more details https://callstack.github.io/react-native-paper/docs/components/Switch/