Gloss UIv4.4
Architecture
Style Guide
Primitives
Input
TextNumberTextareaSelectCheckboxRadioToggle
Output7
Actions4
Forms2
Dashboard10
Composites
Compositions
Planning
Applications

Prototypes

Gloss UIv4.4
Architecture
Style Guide
Primitives
Input
TextNumberTextareaSelectCheckboxRadioToggle
Output7
Actions4
Forms2
Dashboard10
Composites
Compositions
Planning
Applications

Prototypes

Toggle

Switch controls for enabling or disabling a single setting. Toggles provide immediate visual feedback with smooth spring physics animation. Use toggles for binary on/off states where the change takes effect immediately without requiring a save action.

Toggle StatesInteractive
Default
Success
Error
Disabled
Off
On

Physics: The toggle thumb uses spring easing (cubic-bezier(0.34, 1.56, 0.64, 1)) for a bouncy, tactile feel. The track color transitions smoothly while the thumb slides with slight overshoot.

Size Variants
Small (36x20)
Medium (44x24)
Large (52x28)
Current State: OFF
Spring Animation
Thumb slides with bouncy overshoot easing
Color Transition
Track smoothly fades from gray to blue
Immediate Effect
Changes apply instantly (no save needed)

Examples

Basic Toggle

Simple toggle with a label for on/off settings.

Controlled Toggle

Manage toggle state with React state for controlled behavior.

Default Checked

Start with the toggle in the on state.

With On/Off Labels

Add text labels inside the toggle track to clarify the state.

With Helper Text

Add additional context below the toggle.

Switch between light and dark themes

Error State

Indicate an issue with the toggle setting.

Cannot change while verification is pending

Success State

Confirm the setting has been applied successfully.

Disabled States

Disable interaction for readonly or unavailable settings.

Variant Styling

Use the variant prop for different visual emphasis.

All Sizes Comparison

Compare all three sizes for different use cases.

Settings Panel Pattern

Common pattern for a settings page with multiple toggles.

Email notifications
Receive updates via email
Auto-save
Save changes automatically
Dark mode
Use dark theme

Feature Flags Pattern

Use toggles for enabling/disabling features in admin panels.

Enable experimental features (may be unstable)
Help us improve by sending anonymous usage data
Get smart recommendations powered by AI

Best Practices

Do

  • Use for immediate on/off states
  • Label clearly what the toggle controls
  • Show current state visually (color/position)
  • Use for settings that take effect immediately
  • Place label on the left for list layouts

Don't

  • Don't use if a save button is required
  • Don't use for selecting from multiple options
  • Don't use negative labels ("Disable X")
  • Don't use toggles for form submissions
  • Don't mix toggles and checkboxes for similar actions

Toggle Props

PropTypeDefaultDescription
checkedboolean-Controlled on state
defaultCheckedbooleanfalseInitial on state (uncontrolled)
onChange(e: ChangeEvent) => void-Native change event handler
onCheckedChange(checked: boolean) => void-Convenience handler with boolean value
labelReactNode-Label text
onLabelReactNode-Text shown in track when on
offLabelReactNode-Text shown in track when off
helperTextstring-Helper text below toggle
variant'default' | 'success' | 'error''default'Visual variant styling
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Toggle size
disabledbooleanfalseDisable the toggle

Accessibility

  • Role: Uses role="switch" for proper semantics
  • Keyboard: Space to toggle, Tab to navigate
  • ARIA: Uses aria-checked to announce state
  • Focus: Visible focus ring for keyboard navigation
  • Color: Don't rely solely on color - position also indicates state

Toggle vs Checkbox

Use Toggle WhenUse Checkbox When
Change takes effect immediatelyChange requires a save/submit action
Single on/off settingMultiple independent options
Settings/preferences panelForm with submit button
Mobile-like interfacesTraditional desktop forms