qds-switch is a boolean setting control. It exposes a native checkbox with role="switch", a visible label, and native form association. Use checkbox when the visual meaning is an item selection or acknowledgement; use switch for an on/off setting.
<qds-switch label="Email notifications" checked></qds-switch>
<qds-switch name="alerts" value="enabled" label="Alerts" hint="Notify me about portfolio changes"></qds-switch>
<qds-switch label="Required setting" required validate-on="input"></qds-switch>
<qds-switch label="Managed setting" checked readonly></qds-switch>
Load assets/components/switch/qds-switch.js independently. Use label for plain text, or the default slot for label content. Do not put interactive controls in that slot. aria-label and aria-labelledby support externally supplied names; the latter copies the referenced label text across the shadow boundary on synchronization. The visible label must stay constant when checked state changes.
checked is the current boolean state. checked attribute / defaultChecked property set the reset default; a dirty current state is preserved when its default changes. value is a separate native submission string, defaulting to on. Unchecked switches contribute no form entry. Checked switches submit name=value. Angular forms bind a boolean through the generated switch adapter, without replacing the submission value.
form.reset() restores defaultChecked; browser state restoration restores the checked state. Programmatic assignment, reset, and restoration do not emit user events. User toggles emit one input and one change, each bubbling/composed with { component, checked, value }.
disabled and disabled fieldsets block input and exclude the switch from submission. readonly preserves state while remaining focusable and submitted. required requires checked=true. invalid, error-text, and setCustomValidity() allow host validation. checkValidity(), reportValidity(), validity, and validationMessage expose the contract; qds-validity-change reports transitions. Custom validity persists until explicitly cleared. validate-on="blur|input|submit" controls when errors appear, not submission validity.
Tab focuses the native switch. Space toggles it; Enter retains native checkbox behavior and does not toggle. Clicking anywhere on the label toggles it. Role, checked, required, readonly, hint, and visible error semantics are exposed on the native control. All sizes retain a 44px target; size="sm|md|lg" adjusts typography. Semantic tokens support both themes; forced colors, RTL thumb motion, focus outlines and reduced motion are supported.
CSS parts: container, row, input, track, thumb, label, hint, error. Interactive demonstration covers default/checked, custom value, validation, readonly/disabled, label composition, and reset.
The hint/error area reserves one line and the height of either current message, including wrapped text. Hidden messages remain inaccessible; revealing an error on blur keeps nearby actions in place during a pointer click.