esfiles / frontend /src /components /Switch.tsx
Besjon Cifliku
feat: initial project setup
db764ae
interface Props {
checked: boolean;
onChange: (checked: boolean) => void;
label?: string;
}
export default function Switch({ checked, onChange, label }: Props) {
return (
<label className="switch">
<button
className={`switch-track ${checked ? "switch-track-on" : ""}`}
onClick={() => onChange(!checked)}
type="button"
role="switch"
aria-checked={checked}
>
<span className="switch-thumb" />
</button>
{label && <span className="switch-label">{label}</span>}
</label>
);
}