Skip to content
Storybook

Switch

Toggle for settings that take effect immediately. In Figma this is “Toggle”.

Preview

React · live from the Storybook

HTML and CSS

The same component as plain HTML with pixels-ui.css, no framework needed.

Usage

  • No Save button: the change applies at once.
  • Label says what is on, not “Enable/Disable”.

Installation

Included in the core files. No extra install.

HTML
<link rel="stylesheet" href="/css/pixels-tokens.css">
<link rel="stylesheet" href="/css/pixels-ui.css">
<script src="/js/pixels-ui.js" defer></script>

Examples

Sizes

Small, Medium and Large.

Disabled

API reference

Class / attributeTypeDescription
px-switchclassLabel wrapper.
px-switch__trackclassPut on <input type="checkbox" role="switch">.
px-switch--sm · --lgclassSize.

Figma properties

Toggle60 variants · page “Toggles”Open

Switch with label and optional hint for settings that take effect immediately. RTL places the switch on the right. RTL text: Label/Hint properties drive LTR variants; in RTL instances edit the Arabic …

PropertyTypeValues
LabelText“Email notifications”
HintText“Get an email when someone mentions you.”
Show hintBoolean—
SizeVariantSmall Medium Large
OnVariantFalse True
StateVariantActive Hover Pressed Focused Disabled
DirectionVariantLTR RTL
Toggle / Control60 variants · page “Toggles”Open

The bare switch. Applies immediately (no Save button). In RTL the On knob sits on the left. role=switch with aria-checked.

PropertyTypeValues
SizeVariantSmall Medium Large
OnVariantFalse True
StateVariantActive Hover Pressed Focused Disabled
DirectionVariantLTR RTL

Design tokens

Component tokens from the Figma Component collection. Override them to restyle just this component.

TokenAliasLight value
--px-toggle-width-sm28px28px
--px-toggle-height-smspacing-1616px
--px-toggle-knob-sm12px12px
--px-toggle-width-md36px36px
--px-toggle-height-mdspacing-2020px
--px-toggle-knob-md16px16px
--px-toggle-width-lg44px44px
--px-toggle-height-lgspacing-2424px
--px-toggle-knob-lg20px20px
--px-toggle-padding2px2px
--px-toggle-radiusradius-full999px
--px-toggle-gapspacing-1212px

Accessibility

  • role="switch" announces on/off.
  • In RTL the knob mirrors.