Toggle switch

Also called switch or toggle

An on/off control shaped like a small track with a sliding knob, used for settings that take effect immediately.

What is Toggle switch?

A toggle switch mimics a physical switch: a pill-shaped track with a round knob that slides from one end to the other. The track changes color with it, usually gray for off and an accent color for on, so the state reads at a glance.

Use a switch for a setting that applies right away, like push notifications or dark mode. If the choice only takes effect after someone presses Save, a checkbox is clearer. Label the switch with the thing it controls, such as Weekly summary, and let the knob show whether it is on.

A small spring makes the knob feel physical: a quick slide of 150 to 250ms with only a hint of overshoot. Use role='switch' with aria-checked, or a native checkbox styled as a switch, make the whole row clickable, and rely on the knob's position as well as color to show the state.

Often confused with

Checkbox
A checkbox suits choices that apply when a form is submitted, or selecting several items. A switch applies a setting the moment you flip it.
All terms

Checkbox

A small square you tick to turn an option on or select an item, with a dash in a parent box when only some items are checked.

Spring animation

An animation driven by simulated spring physics in place of a fixed duration and curve, so motion can overshoot, settle, and react naturally.

Optimistic UI

A pattern where the interface shows the result of an action right away, before the server confirms it, and rolls it back if the request fails.

Micro-interaction

A small moment of feedback around a single action, like a heart that bursts when tapped or a copy icon that turns into a checkmark.