Toggle

Switches a setting on or off, taking effect immediately.

Refined portVue source: WildToggle.vueStorybook story: Forms/ToggleReact component: WToggle

Try it

Click it, or tab to it and press Space or Enter.

Size
Label
Disabled
<WildToggle
  v-model="enabled"
  size="md"
  label="Send SMS alerts"
/>

When to use

  • Use a toggle for a setting that takes effect the moment it’s flipped.
  • Use it for one setting at a time, each with its own label.
Don’t use it
  • For an option that waits for Save. Use a checkbox, so nobody wonders whether their change took effect.
  • To pick one of several. Use a radio group.

Anatomy

A track and a knob, with an optional label to the right. The label is part of the target.

Send SMS alertsInclude archived sites
<WildToggle v-model="enabled" label="Send SMS alerts" />

Sizes

Two sizes, each with 2px between the knob and the track. The default is md.

md · 44×24 / knob 20
sm · 36×20 / knob 16

States

off
on
hover
pressed
focus
disabled · off
disabled · on
Off is grey, so switching an alert off reads as quiet rather than as a fault.

Accessibility

A screen reader hears the label, then on or off. A toggle with no visible label needs ariaLabel.

KeyWhat it does
TabMoves focus to the toggle. A disabled one is skipped.
Space / EnterFlips it.

Props

PropTypeDefaultDescription
onboolean—Whether the setting is on.
onChange(on: boolean) => void—Makes it operable. Called with the next value.
labelstring—Text to the right of the track.
size'md' | 'sm''md'44×24 or 36×20.
disabledbooleanfalseDims it to 50% and leaves the tab order.
state'rest' | 'hover' | 'active' | 'focus'—Forces a frame, for static examples.
ariaLabelstring—Accessible name when there is no label.

Tokens

TokenValueWhere it lands
--radius-full9999pxTrack and knob.
--color-primary#00AEEFTrack when on.
--color-primary-hover#0ABEFFTrack when on, on hover.
--color-primary-active#1877F2Pressed track when on, and the focus ring.
--global-neutral-grey-900#7F7D83Track when off, 4.1:1. A disabled switch keeps a lighter grey.
--global-neutral-grey-1000 / -1100#4F4D55 / #2D2B32Off track on hover and press.
--ease-in-outcubic-bezier(.4,0,.2,1)Knob travel, 150ms.
(no token)2px gap, 2px ringKeyboard focus, outside the track.