Toggle switch styling reference
On this page
Toggle switches are the on/off switches at the end of a row in the POS Hardware settings, such as the On-screen number pad setting. Operators tap a toggle switch to turn a setting on or off, and the round knob slides to the right when the setting is on. You can change the fill and border of the toggle switch track and the fill and border of the knob. Follow the POS styling API rules when you style toggle switches.
Where a toggle switch appears
Toggle switches appear in these Hardware settings:
- The On-screen number pad setting
- The Connect cash drawer setting on a printer
- The payment types that open the cash drawer, under Cash drawer triggers
Parts
| Part | What it is | Available from |
|---|---|---|
toggle-switch-root |
The whole switch: the rounded track, with the fill and border, that the thumb slides along. | v22.0.19 |
toggle-switch-thumb |
The round knob inside the track, at the left when the switch is off and at the right when it’s on. | v22.0.19 |
The Available from column shows the first release that carries the name.
Attributes
Narrow toggle-switch-root by this, inside :where(), to style a switch that’s on or one that’s off.
| Attribute | Values | Default | Available from |
|---|---|---|---|
data-checked |
true, false |
false |
v22.0.19 |
true: the setting is on. The track takes the primary color and the thumb sits at the right.false: the setting is off. The track is light gray and the thumb sits at the left.
Component properties
None yet. Style the parts directly.
Examples
Each example is tested against the POS on every change.
“Give the switches that are on our brand color.” The thumb of a switch that’s on has a border in the primary color, so set the thumb border to the brand color as well:
```css
background-color: #0b5394; border-color: #0b5394; }
border-color: #0b5394; } ```
“Give the switches that are off a darker track.”
```css
background-color: #c4c9d0; } ```
“Make the thumb a warmer white.”
```css
[part~=’toggle-switch-thumb’] { background-color: #fffaf0; } ```
“Drop the switches’ border.”
```css
part~=’toggle-switch-root’ { border-color: transparent; } ```
What can’t be styled yet
- One switch on its own, such as the on-screen number pad’s, since no switch has a name yet
- A switch while it’s hovered, apart from the other states: a fill you set on a switch that’s off also replaces the darker fill it takes while hovered
- A switch that can’t be changed, since no screen draws one
- The colors of a switch through the POS design tokens: the track and thumb use fixed colors, apart from the primary color of a switch that’s on
Retired
None yet.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.