import * as React from 'react'; import { cn } from '../utils/cn'; export interface SwitchProps extends Omit< React.InputHTMLAttributes, 'type' > { label?: string; onCheckedChange?: (checked: boolean) => void; } const Switch = React.forwardRef((props, ref) => { const { className, label, id, checked, onCheckedChange, onChange, disabled, ...restProps } = props; const switchId = id || React.useId(); const isChecked = checked ?? false; // Destructure restProps to omit attributes that cause React warnings/errors on buttons const { type: _type, ...buttonProps } = restProps as any; const handleChange = (e: React.ChangeEvent) => { onChange?.(e); onCheckedChange?.(e.target.checked); }; return (
); }); Switch.displayName = 'Switch'; export { Switch };