Skip to content
SuperCoach

Components · Inputs

Switch

Beta

A setting that takes effect immediately, such as check-in reminders.

Remind clients the day before their weekly check-in.

When to use

  • For a setting that takes effect as soon as it changes: check-in reminders, accepting new clients, showing calories to clients.

When not to use

  • Inside a form that is saved with a button: use a Checkbox.
  • To choose between two things that are not on and off ("kg" or "lb"): use a Radio group.

Anatomy

  1. 1. Label, and an optional description
  2. 2. Track and thumb: the thumb moves to the end when on

Variants

Two sizes: default for settings pages, sm inside table rows and dense lists.

States

StateWhat changesToken
OffNeutral trackbg-input
OnTrack in the primary color, thumb at the endbg-primary
Focus-visibleRingring-ring/50
DisabledHalf opacityopacity-(--opacity-disabled)

Usage guidelines

  • Apply the change immediately and confirm it ("Reminders turned on") only if it affects clients.
  • Put the switch at the end of the row, with its label at the start, in settings lists.
  • If a change can't apply instantly (it needs saving or loading), show a spinner or use a checkbox instead.

Content guidelines

  • The label names the setting, not the action: "Check-in reminders", not "Turn on reminders".
  • Don't add "On" and "Off" text next to the switch; the state is announced.

Accessibility

KeyDoes
TabMoves to the switch
Space or EnterToggles it
  • Rendered as role="switch" with aria-checked. Announced as "Check-in reminders, switch, on".

RTL

The thumb moves toward the end edge when on: left in RTL. The upstream component only moved it right, so it slid out of the track in RTL; this version adds the mirrored transform.

Tokens used

Read from components/ui/switch.tsx at build time, so this list changes when the component does. Opacity modifiers such as /90 are shadcn hover and focus tints on top of the token.

Semantic color tokens used by this component
TokenUtilitiesSuperCoachCoach
--backgroundbg-backgroundwhitewhite
--inputbg-inputneutral-200neutral-200
--primarybg-primarybrand-600orange-500
--ringborder-ring ring-ring/50brand-600orange-500
  • Opacityopacity-(--opacity-disabled)
  • Radiusrounded-full
  • Shadowshadow-xs

Props

<Switch>

Also takes every prop of Radix Switch.Root

Switch props
PropTypeDefault
size?"sm" | "default""default"

Replaces in coach-admin

From the read-only audit of coach-admin: 44 style values, 56 uses.

Classes and selectors

  • .switch-label7
  • .switch-handle7
  • .switch-label::before, .switch-label::after3
  • .switch-label::before1
  • .switch-label, .switch-handle1

Files

  • src/reusableComponents/features/featureToggle.scss37

The inventory lists the first 12 locations of each value, so file counts are a lower bound.

SCSS variables in these styles

  • $spacing-smnot a color: spacing, size or layout
  • $spacing-xsnot a color: spacing, size or layout
  • $heightnot a color: spacing, size or layout
  • $handle-marginnot a color: spacing, size or layout
  • $light-surface-bg→ --muted
  • $font-sizenot a color: spacing, size or layout
  • $light-primary-colornot a color: spacing, size or layout
  • $primary-border-colornot a color: spacing, size or layout
  • $primary-color-hovernot a color: spacing, size or layout
  • $gray-200→ nearest neutral-300 (no semantic token)
  • $gray-100→ nearest neutral-100 (no semantic token)
  • $primary-color→ --primary

Checkbox, Radio group.