import { useState } from "react"; import * as PrimitiveSwitch from "@radix-ui/react-switch"; import * as Label from "@radix-ui/react-label"; function classNames(...classes) { return classes.filter(Boolean).join(" "); } export default function Switch(props) { const { label, onCheckedChange, ...primitiveProps } = props; const [checked, setChecked] = useState(props.defaultChecked || false); const onPrimitiveCheckedChange = (change: boolean) => { if (onCheckedChange) { onCheckedChange(change); } setChecked(change); }; return (
{label && ( {label} )}
); }