Components
Switch
Switch component
The Switch
component is used to toggle between two states. You can find this component in the /components
folder.
You can use the Switch
component in your code like this:
Switch.js
const [isEnabled, setIsEnabled] = useState(false);
const toggleSwitch = () => setIsEnabled(previousState => !previousState);
export default function switch() {
return (
<Switch
trackColor={{ false: "#d1d5db", true: "#AAB2FF" }}
thumbColor={isEnabled ? "#AA8CFF" : "#f9fafb"}
onValueChange={toggleSwitch}
value={isEnabled}
/>
)
}