// Boolean toggle with immediate effect (as opposed to Checkbox, which is part of a form submit). // `role="switch"` on a native checkbox keeps keyboard behaviour — and its checked state, which is // why nothing here writes `aria-checked`: `role="switch"` maps the host `checked` state on its own, // and an attribute mirroring it never updates on the no-JS path, where ARIA would then outrank the // truth and announce the switch stuck in whichever position it was rendered in. import type { JSX } from 'solid-js'; import { cx } from '../cx'; import styles from './Switch.module.scss'; export interface SwitchProps { /** Already-translated label. Required — the state alone is not a name. */ label: string; checked?: boolean | undefined; id?: string | undefined; name?: string | undefined; disabled?: boolean | undefined; /** Put the label before the track, e.g. in a settings row. */ labelPosition?: 'start' | 'end' | undefined; class?: string | undefined; 'aria-describedby'?: string | undefined; onChange?: JSX.EventHandlerUnion | undefined; } export function Switch(props: SwitchProps): JSX.Element { return ( ); }