Resonance Logo

Toggle Switch

A toggle switch provides an immediate on/off control that takes effect right away, with its current state communicated visually and through ARIA attributes for assistive technology.

Demo

Click or tap the toggle to switch it between on and off. Then tab to it with the keyboard and press Space to activate it. Listen with a screen reader to confirm that the new state — "on" or "off" — is announced immediately after each interaction without requiring a page reload or form submission.

Automatically save your work every 30 seconds.

What to Observe

Anatomy

[Anatomy image placeholder — will be added when assets are available]

  1. Label: A visible text label identifying what the toggle controls, persistently displayed regardless of the current state.
  2. Track: The elongated pill-shaped background element that visually represents the switch housing; its fill color typically changes between states.
  3. Thumb: The circular element that slides left (off) or right (on) within the track to indicate the current state.
  4. State indicator: Optional text inside or beside the track ("On" / "Off") providing an additional non-color cue for the current state.
  5. Interactive control: The underlying button or checkbox element that receives focus, carries the ARIA switch role and checked state, and handles keyboard activation.

Accessibility Behavior

Common Mistakes

Why This Matters

Toggle switches appear in settings panels, feature flags, notification preferences, and privacy controls — all places where users need to make quick binary decisions. A toggle that communicates its state only through visual position or color gives blind users and keyboard-only users no way to know whether a setting is on or off. In critical contexts like privacy permissions or accessibility settings, this is not just an inconvenience — it means users cannot make informed choices about their own experience. Implementing the switch role and live state updates closes that gap entirely.

Accessibility Validation

This component is validated against internal accessibility criteria aligned with WCAG standards, using our internally developed system, Resonance Specs.

To learn more, please contact us.

Code

Reference Implementation