import React from "react"; /** * Product switch — track/thumb from --switch-* tokens. * Keyboard: Space/Enter toggles. role="switch" + aria-checked; the visible * label supplies the accessible name. */ export function Switch({ checked, defaultChecked = false, onChange, disabled = false, label, describedBy, style }) { const [internal, setInternal] = React.useState(defaultChecked); const on = checked !== undefined ? checked : internal; const labelId = React.useId(); const toggle = () => { if (disabled) return; if (checked === undefined) setInternal(!on); if (onChange) onChange(!on); }; const onKeyDown = (e) => { if (e.key === " " || e.key === "Enter") { e.preventDefault(); toggle(); } }; return ( {label && {label}} ); }