If you’re looking for a simple switch component, the simplest way to do this is with the react-switch library. Start by installing the library with NPM: npm install react-switch Import the React, useState and the Switch component from the react-switch library and create your switch component. For more options for styling, check out the docs here import React, { useState } from "react";
import Switch from "react-switch";
const SwitchExample = () => {
const [checked, setChecked] = useState(false);
const handleChange = (checked) => {
setChecked(checked);
}
return (
<label>
<span>Switch with default style</span>
<Switch onChange={handleChange} checked={checked} />
</label>
);
}