/** * @file SwitchInput component */ import React from "react"; import styles from "./SwitchInput.module.css"; export type SwitchInputProps = { checked: boolean; onChange: (checked: boolean) => void; disabled?: boolean; size?: "small" | "medium" | "large"; label?: string; id?: string; className?: string; }; export const SwitchInput: React.FC = ({ checked, onChange, disabled = false, size = "medium", label, id, className = "", }) => { const classes = [styles.switch, className].filter(Boolean).join(" "); const handleClick = () => { if (!disabled) { onChange(!checked); } }; const handleKeyDown = (event: React.KeyboardEvent) => { if (event.key === " " || event.key === "Enter") { event.preventDefault(); handleClick(); } }; return (
{label && ( )}
); };