Files
coco-app/src/components/Settings/SettingsToggle.tsx

27 lines
633 B
TypeScript
Raw Normal View History

2025-12-18 10:26:13 +08:00
import { Switch } from "@/components/ui/switch";
import clsx from "clsx";
2024-10-28 17:34:48 +08:00
2025-12-18 10:26:13 +08:00
type BaseSwitchProps = React.ComponentProps<typeof Switch>;
interface SettingsToggleProps
extends Omit<BaseSwitchProps, "onChange" | "onCheckedChange"> {
2024-10-28 17:34:48 +08:00
label: string;
className?: string;
2025-12-18 10:26:13 +08:00
onChange?: (checked: boolean) => void;
2024-10-28 17:34:48 +08:00
}
export default function SettingsToggle(props: SettingsToggleProps) {
2025-12-18 10:26:13 +08:00
const { label, className, onChange, ...rest } = props;
2024-10-28 17:34:48 +08:00
return (
<Switch
{...rest}
2025-12-18 10:26:13 +08:00
aria-label={label}
onCheckedChange={(v) => onChange?.(v)}
className={clsx(
2025-12-18 10:26:13 +08:00
"h-5 w-9",
className
)}
2025-12-18 10:26:13 +08:00
/>
2024-10-28 17:34:48 +08:00
);
}