/* This example requires Tailwind CSS v2.0+ */ import { useState } from "react"; import { Switch } from "@headlessui/react"; import classNames from "../../../utils/helpers/className"; export default function ToggleButton() { const [enabled, setEnabled] = useState(false); return ( <Switch checked={enabled} onChange={setEnabled} className={classNames( enabled ? "border-2 border-violet-500 bg-black" : "border-2 border-black bg-white", "relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" )} > <span className="sr-only">Use setting</span> <span aria-hidden="true" className={classNames( enabled ? "translate-x-tog1 translate-y-[0.094rem] bg-violet-600" : "translate-x-[0.094rem] translate-y-[0.125rem] bg-black", "pointer-events-none inline-block h-[0.813rem] w-[0.813rem] transform rounded-full bg-violet-600 shadow ring-0 transition duration-200 ease-in-out" )} /> </Switch> ); }