Switch

Switches toggle the selection of an item on and off.

Usage

Switch toggles a single setting on or off. It renders role="switch", not a native form control, so associate an accessible name with aria-label or aria-labelledby.

Checked and disabled states

Use checked with onCheckedChange in React, [(checked)] in Angular, or bind:checked in Svelte. defaultChecked captures the initial uncontrolled state. A controlled switch emits a request but does not change until its owner supplies the new value. Use disabled to prevent interaction.

With icons

Provide activeIcon and/or inactiveIcon to display inside the thumb. The thumb slide between positions is driven by a shared @udixio/core/dom controller, so React, Angular and Svelte animate identically.

Accessibility

Switch exposes aria-checked and toggles with a click or with Space/Enter when focused. It never renders a visible label on its own; pair it with aria-label, aria-labelledby, or a visible label element referencing it through your own markup.