agents/projects/chrome-design-system/assets/component-specs/Switch_Spec.md
This specification document outlines the mapping, design tokens, styling variants, and interactive states of the Switch (Slide Toggle / Toggle Button) component across Figma, C++ Views, and WebUI (Web Frontend).
The Switch component represents a sliding, standard physical switch used for simple on/off or enabled/disabled toggle configurations. It consists of an elongated pill-shaped background track and a nested solid circular handle that slides horizontally.
| Feature | Figma Component | C++ Views (Desktop) | WebUI (Web Frontend) |
|---|---|---|---|
| Component Name | Switch | views::ToggleButton | <cr-toggle> |
| Source Files | Figma Link: 280:26373 | ui/views/controls/button/toggle_button.h | ui/webui/resources/cr_elements/cr_toggle/cr_toggle.ts |
| Feature / Variant | Figma Component | C++ Views (Desktop) | WebUI (Web Frontend) |
|---|---|---|---|
| Selected (On) | selected=true | Handle shifts right; track turns primary blue | Attribute: checked is active |
| Unselected (Off) | selected=false | Handle shifts left; track turns grey | Default unchecked/off state |
| State | Figma Component | C++ Views (Desktop) | WebUI (Web Frontend) |
|---|---|---|---|
| Default (Normal) | state=Default | Button::ButtonState::STATE_NORMAL | Standard slide toggler appearance |
| Disabled | state=Disabled | Button::ButtonState::STATE_DISABLED | Attribute: <cr-toggle disabled> |
| Design Attribute | Figma Design Token | C++ Views (Desktop) | WebUI (Web Frontend) |
|---|---|---|---|
| Selected Track Color | --desktop/sys/primary-colors/primary | ||
(#0b57d0) | ui::kColorToggleButtonTrackOn | --cr-toggle-checked-bar-color | |
| Selected Handle Color | --desktop/sys/primary-colors/on-primary | ||
(white) | ui::kColorToggleButtonThumbOn | --cr-toggle-checked-button-color | |
| Unselected Track Color | --desktop/sys/surface-colors/surface-variant | ||
(#e1e3e1) | ui::kColorToggleButtonTrackOff | --cr-toggle-unchecked-bar-color | |
| Unselected Handle Color | --desktop/sys/outline-colors/outline | ||
(#747775) | ui::kColorToggleButtonThumbOff | --cr-toggle-unchecked-button-color | |
| Disabled Track Color | --desktop/sys/state-colors/state-disabled-container | ||
(rgba(31,31,31,0.12)) | ui::kColorToggleButtonTrackOnDisabled / OffDisabled | --cr-toggle-disabled-bar-color | |
| Disabled Handle Color | --desktop/sys/state-colors/state-disabled | ||
(rgba(31,31,31,0.38)) | ui::kColorToggleButtonThumbOnDisabled / OffDisabled | --cr-toggle-disabled-button-color | |
| Corner Radius (Fully) | --desktop/corner-radius/fully-rounded | ||
(999px) | Oval geometry matches bounded track borders | border-radius: 999px; on track and thumb | |
| Track Dimensions | 26px Width, 16px Height | Configured inside slide layout metrics | width: 26px; height: 16px; |
SlideAnimation) inside toggle_button.cc to smoothly animate the thumb handle across the track upon toggles.transition: transform 150ms;) defined inside cr_toggle.css.<cr-toggle> (especially on touch-enabled platforms) and Views views::ToggleButton support swipe/drag input gestures in addition to standard clicks, allowing users to physically drag the slider handles across the track boundaries.role="switch" and track state via aria-checked.views::View (Base layout unit)
└── views::Button (Focus, click handlers)
└── views::ToggleButton (Handles track bounds, thumb sliders, and slide animations)
HTMLElement (Browser element base)
└── CrLitElement (Lit reactive UI component)
└── CrToggleElement (Reusable cr-toggle element)