Components / component

Toggle Switch

v1.0.0 · premium

A switch whose thumb stretches under the finger and springs across, filling the track as it turns on.

Toggle Switch demo

Implementation

A switch whose thumb stretches under the finger and springs across, filling the track as it turns on.

Framework
React 19.3.1 with TypeScript
Motion
Native CSS and browser APIs. No GSAP required.
Available modes
build
Version
1.0.0 · published

Source code

Download source ZIP
export function ToggleSwitch({ label, checked, defaultChecked = false, onChange, disabled = false, size = 'md', ink, pap
  /** Visible label. It is also the accessible name. */
  label: string;

Quality evidence

Export tested in 2 consumer projects with chromium, firefox, webkit. Evidence recorded on .

Changelog

v1.0.0 · A switch whose thumb stretches under the finger and springs across, filling the track as it turns on.

Frequently asked questions

Is it announced as a switch?

Yes. It is a button with role switch and aria-checked, so assistive technology reads it as a switch with its on or off state.

How do I submit its state with a form?

Read the value from onChange and send it yourself, or mirror it into a hidden input. It is a button, so it does not submit by itself.