Skip to content
HomeCobalt

Switch

A setting that takes effect the moment it flips, on or off, with nothing to save.

Examples

Settings that take effect the moment they flip, one per row with the switch at its end; a failed save moves the switch back and says so.
Pending while it savesTwo-step sign-in applies only once the server accepts it, so the switch holds where it was put and the row says Saving until the answer; a refusal moves it back and says so.

Variants

DefaultA 44 by 20 track with a 24 by 16 thumb, for a setting in a list or a form.
  • Northgate Credit 13F
  • Elm Street Value Form D
SmallA 28 by 16 track with a 16 by 12 thumb, for a setting inside a dense row such as a table cell.

States

DisabledOff and on at half opacity, the words faded too, each saying why it cannot change.

Usage

Use it when

  • You turn a setting on or off and it applies at once: notifications, sounds, a theme, sharing.
  • A row in a settings list holds one such setting, the word first and the switch at the end.

Use something else when

  • The change applies only when the form is saved. Use Checkbox instead.
  • Exactly one of a few options may be chosen. Use SegmentedControl instead.
  • The on state is a filter in a row of chips, or a button that stays pressed. Use Pill or Toggle instead.

Rules

General

Content

Avoid

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/switch.json
import { Switch } from "@/components/cobalt/ui/switch"