API
Switch
A checkbox with `role="switch"`, drawn as a toggle.
Installation
pnpm dlx zazz-ui add switchnpx zazz-ui add switchyarn dlx zazz-ui add switchbunx zazz-ui add switchAlso adds fields, which it depends on. Run zazz-ui init first if the project has no zazz/ folder yet.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->
<meta name="color-scheme" content="light dark">
<!-- Zazz styles: base layers, then fields, switch in cascade order -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_layers.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_variables.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_shadows.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_breakpoints.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_reset.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_typography.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_view-transitions.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/primitives/fields/fields.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/primitives/switch/switch.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-sm.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-md.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-lg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-2xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-disabled.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-active.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-focus-visible.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-focus-within.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-hover.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-checked.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-current.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-open.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-stuck.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_properties-starting.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-sm.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-md.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-lg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-2xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-disabled.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-active.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-focus-visible.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-focus-within.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-hover.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-checked.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-current.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-open.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-stuck.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-tier-starting.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-flow.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-grid.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-spacing.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-margin.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-sizing.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-typography.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-color.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-effects.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-box.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-pseudo.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_defaults.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/_utilities-sr.css">
<!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
<script type="importmap">
{
"imports": {
"signal-polyfill": "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js"
},
"integrity": {
"https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js": "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK"
}
}
</script>
<!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
<script type="module" src="https://cdn.jsdelivr.net/npm/invokers@2.2.2/dist/esm/production/interest.js" integrity="sha384-hR2BVNtsS7fIIMwOm+f7MY0JZfuByGhQQfevCBB6evFATKzBsTw0JzH/RxD94z2T" crossorigin="anonymous"></script>
<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.16.0/src/base/dialog-lifecycle.js"></script>
<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
<script>
(() => {
try {
// A stored choice pins the scheme with data-theme; with no choice the
// page follows the system scheme.
const storedTheme = localStorage.getItem("theme");
if (storedTheme === "dark" || storedTheme === "light") {
document.documentElement.dataset.theme = storedTheme;
}
} catch {
/* no storage access: follow the system scheme */
}
})();
</script>A <head> that loads the base layers and switch with its dependencies from jsDelivr, pinned to 0.16.0. To load the whole kit in two requests, see the CDN install.
Examples
<fieldset data-ui="field-group">
<legend>Notifications</legend>
<div
style="
--display: flex-col;
--gap: 2;
"
>
<label data-ui="field" data-field-orientation="horizontal">
<input type="checkbox" role="switch" name="notifications-email" />
<span data-field-slot="label">Email notifications</span>
</label>
<label data-ui="field" data-field-orientation="horizontal">
<input type="checkbox" role="switch" name="notifications-2fa" checked />
<span data-field-slot="label">Two-factor authentication</span>
</label>
</div>
</fieldset>/**
* switch.css — Switch (input[type="checkbox"][role="switch"])
*
* @layer variables, reset
* @requires _layers.css, _variables.css, _properties.css (--_*-resolved, --_focus-shadow), fields.css (--ui-field-* border/ring)
* @uses appearance: none on input[role="switch"]
* @uses --_touch-min (touch screens) — the track keeps its size; an invisible ::after
* on the input, centred on it, is at least the touch floor square
* @uses label:has(> input[role="switch"])::after — thumb drawn on label (no JS)
* @uses oklch(from …) — checked/hover track tints
* @uses corner-shape — the track and thumb follow the field shape. A concave shape at a
* full radius empties a circle, and CSS can't read the number in superellipse(), so
* each part keeps a convex shape from this list (round, squircle, square,
* superellipse(1 | 1.3 | 2 | infinity)) and draws anything else round; the check is an
* if(). Only Chromium and Safari draw corner-shape, and both support if(); where if()
* is missing the private is invalid and its round fallback draws. The
* --corner-shape utility still sets any shape on the track.
* @tokens --ui-switch-* (@layer variables; consumed in @layer reset; border and
* ring default to the --ui-field-* family; --ui-switch-w-coefficient and
* --ui-switch-h-coefficient stretch the track and thumb together)
*/
@layer variables {
:root {
/* stretch the switch along one axis: the track scales by it and the thumb grows
with it, so the gap around the thumb stays the same. Read in the rules below,
so they work on any element, not only :root */
--ui-switch-w-coefficient: 1;
--ui-switch-h-coefficient: 1;
/* floored so the track stays at least --spacing-control-min tall */
--ui-switch-track-w: max(calc(var(--spacing) * 7), calc(var(--spacing-control-min) * 1.75));
--ui-switch-track-p: max(calc(var(--spacing) * 0.5), calc(var(--spacing-control-min) * 0.125));
--ui-switch-track-h: calc(
var(--ui-switch-track-w) / 2 + var(--ui-switch-track-p) + var(--ui-switch-track-border-width)
);
--ui-switch-thumb-bg: var(--color-card);
--ui-switch-thumb-bg--checked: var(--color-primary-foreground);
--ui-switch-thumb-border-width: var(--ui-field-border-width);
--ui-switch-thumb-border-style: var(--ui-field-border-style);
--ui-switch-thumb-border-color: var(--ui-field-border-color);
--ui-switch-thumb-border-color--hover: var(--ui-field-border-color--hover);
--ui-switch-thumb-border-color--checked: transparent;
--ui-switch-thumb-border-color--checked-hover: transparent;
/* the thumb is content-box: its border sits outside this size, so take it back out
and the gap around the thumb is the same on every side. Half the track wide and
the track's height tall, so with the default track it's a circle */
--ui-switch-thumb-w: calc(
(var(--ui-switch-track-w) / 2) - var(--ui-switch-track-p) -
var(--ui-switch-thumb-border-width)
);
--ui-switch-thumb-h: calc(
var(--ui-switch-track-h) - 2 * var(--ui-switch-track-p) - 2 *
var(--ui-switch-thumb-border-width)
);
--ui-switch-thumb-shadow: var(--shadow-xs);
--ui-switch-thumb-translate: var(--ui-switch-track-p), -50%;
--ui-switch-thumb-scale: 1;
--ui-switch-track-bg: var(--color-input);
--ui-switch-track-bg--hover: oklch(from var(--color-muted) l c h / calc(alpha * 1.5));
--ui-switch-track-bg--checked: var(--color-primary);
--ui-switch-track-bg--checked-hover: var(--color-primary);
--ui-switch-track-border-width: var(--ui-field-border-width);
--ui-switch-track-border-style: var(--ui-field-border-style);
--ui-switch-track-border-color: var(--ui-field-border-color);
--ui-switch-track-border-color--hover: var(--ui-field-border-color--hover);
--ui-switch-track-border-color--checked: var(--ui-field-border-color--hover);
--ui-switch-track-border-color--checked-hover: var(--ui-field-border-color);
/* dual-mode hooks: a scale number or a length */
--ui-switch-radius: var(--radius-full);
--ui-switch-corner-shape: var(--ui-field-corner-shape);
--ui-switch-track-radius: var(--ui-switch-radius);
--ui-switch-track-corner-shape: var(--ui-switch-corner-shape);
--ui-switch-thumb-radius: var(--ui-switch-radius);
--ui-switch-thumb-corner-shape: var(--ui-switch-corner-shape);
--ui-switch-cursor: pointer;
}
}
/* Each part's hook shape, floored (see the header). Read as var(…, round): WebKit drops a
registered "*" property read with no fallback in corner-shape. */
@property --_switch-track-shape {
syntax: "*";
inherits: false;
}
@property --_switch-thumb-shape {
syntax: "*";
inherits: false;
}
/* The coefficient sizes: the track's (--_switch-w/-h) and how much they grow the
thumb (--_switch-grow-w/-h). Each is set and read on the same element. */
@property --_switch-w {
syntax: "*";
inherits: false;
}
@property --_switch-h {
syntax: "*";
inherits: false;
}
@property --_switch-grow-w {
syntax: "*";
inherits: false;
}
@property --_switch-grow-h {
syntax: "*";
inherits: false;
}
@layer reset {
/* ===========================================================================
SWITCH — native <input type="checkbox" role="switch"> internals
In the reset layer so component overrides win.
=========================================================================== */
:where(label:has(> input[role="switch"])) {
position: relative;
&::after {
content: "";
position: absolute;
inset-block-start: 50%;
inset-inline-start: 0;
/* how much the coefficients grow the track: the thumb takes half the width
(it stays half the track) and all of the height, so the gap holds */
--_switch-grow-w: calc(var(--ui-switch-track-w) * (var(--ui-switch-w-coefficient) - 1));
--_switch-grow-h: calc(var(--ui-switch-track-h) * (var(--ui-switch-h-coefficient) - 1));
inline-size: calc(var(--ui-switch-thumb-w) + var(--_switch-grow-w) / 2);
block-size: calc(var(--ui-switch-thumb-h) + var(--_switch-grow-h));
/* The thumb hangs off the label, out of reach of a --radius on the input,
so it reads the hook alone */
--_radius-len: var(--ui-switch-thumb-radius);
--_radius-num: var(--ui-switch-thumb-radius);
border-radius: calc(
var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-coefficient)
);
--_switch-thumb-shape: if(
style(--ui-switch-thumb-corner-shape: round) or
style(--ui-switch-thumb-corner-shape: squircle) or
style(--ui-switch-thumb-corner-shape: square) or
style(--ui-switch-thumb-corner-shape: superellipse(1)) or
style(--ui-switch-thumb-corner-shape: superellipse(1.3)) or
style(--ui-switch-thumb-corner-shape: superellipse(2)) or
style(--ui-switch-thumb-corner-shape: superellipse(infinity)): var(
--ui-switch-thumb-corner-shape
);
else: round
);
corner-shape: var(--_switch-thumb-shape, round);
border-width: var(--ui-switch-thumb-border-width);
border-style: var(--ui-switch-thumb-border-style);
border-color: var(--ui-switch-thumb-border-color);
background-color: var(--ui-switch-thumb-bg);
box-shadow: var(--ui-switch-thumb-shadow);
pointer-events: none;
transform: translate(var(--ui-switch-thumb-translate)) scale(var(--ui-switch-thumb-scale));
transition: var(--default-transition);
z-index: 1;
}
&:has(> input[role="switch"]:checked)::after {
background-color: var(--ui-switch-thumb-bg--checked);
border-color: var(--ui-switch-thumb-border-color--checked);
/* the far end less the gap and the thumb, so a thumb-w hook still lands there:
(track-w + grow) − p − (thumb-w + grow / 2) − both thumb borders */
--ui-switch-thumb-translate:
calc(
var(--ui-switch-track-w) + var(--_switch-grow-w) / 2 - var(--ui-switch-track-p) -
var(--ui-switch-thumb-w) - 2 * var(--ui-switch-thumb-border-width)
),
-50%;
}
@media (hover: hover) {
&:has(> input[role="switch"]:hover:not(:disabled))::after {
border-color: var(--ui-switch-thumb-border-color--hover);
--ui-switch-thumb-scale: 1.1;
}
/* more specific than the plain hover, so a checked thumb keeps its own color */
&:has(> input[role="switch"]:hover:checked:not(:disabled))::after {
border-color: var(--ui-switch-thumb-border-color--checked-hover);
}
}
&:has(> input[role="switch"]:active:not(:disabled))::after {
--ui-switch-thumb-shadow: none;
--ui-switch-thumb-scale: 0.98;
}
}
:where(label:has(> input[role="switch"]:disabled)) {
opacity: 0.5;
cursor: not-allowed;
}
:where(label:has(> input[role="switch"]:disabled) > input[role="switch"]) {
opacity: 1;
}
:where(input[role="switch"]) {
position: relative;
appearance: none;
flex-shrink: 0;
/* touch: the hit area, --_touch-min square at least; collapses to the track on a mouse
(the thumb is the label's ::after, so the input's own is free) */
&::after {
content: "";
position: absolute;
inset: min(0px, calc((100% - var(--_touch-min)) / 2));
}
/* a --w / --h utility sets the size outright; the coefficients scale only the hooks */
--_switch-w: calc(var(--ui-switch-track-w) * var(--ui-switch-w-coefficient));
--_switch-h: calc(var(--ui-switch-track-h) * var(--ui-switch-h-coefficient));
--_w-len: var(--_w-resolved, var(--_switch-w));
--_w-num: var(--_w-resolved, var(--_switch-w));
inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
--_h-len: var(--_h-resolved, var(--_switch-h));
--_h-num: var(--_h-resolved, var(--_switch-h));
block-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
background-color: var(--_bg-resolved, var(--ui-switch-track-bg));
border-width: var(--_border-width-resolved, var(--ui-switch-track-border-width));
border-style: var(--_border-style-resolved, var(--ui-switch-track-border-style));
border-color: var(--_border-color-resolved, var(--ui-switch-track-border-color));
--_radius-len: var(--_radius-resolved, var(--ui-switch-track-radius));
--_radius-num: var(--_radius-resolved, var(--ui-switch-track-radius));
border-radius: calc(
var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-coefficient)
);
--_switch-track-shape: if(
style(--ui-switch-track-corner-shape: round) or
style(--ui-switch-track-corner-shape: squircle) or
style(--ui-switch-track-corner-shape: square) or
style(--ui-switch-track-corner-shape: superellipse(1)) or
style(--ui-switch-track-corner-shape: superellipse(1.3)) or
style(--ui-switch-track-corner-shape: superellipse(2)) or
style(--ui-switch-track-corner-shape: superellipse(infinity)): var(
--ui-switch-track-corner-shape
);
else: round
);
corner-shape: var(--_corner-shape-resolved, var(--_switch-track-shape, round));
cursor: var(--_cursor-resolved, var(--ui-switch-cursor));
/* The ring is published to --_focus-shadow so a --shadow utility keeps
it; the transparent outline twin keeps focus visible in forced-colors */
--_ring-offset-width: 0px;
--_ring-width: 0px;
--_focus-in: max(0, -1 * sign(var(--_focus-ring-w, 1px)));
--_ring-fill: color-mix(in oklch, var(--ui-field-ring-color) var(--ring-opacity), transparent);
--_focus-shadow:
0 0 0 calc(var(--_ring-offset-width) * (1 - var(--_focus-in))) var(--ring-offset-shadow-color),
0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * (1 - var(--_focus-in)))
var(--_ring-fill, var(--ring-shadow-color)),
inset 0 0 0 calc(var(--_ring-offset-width) * var(--_focus-in)) var(--ring-offset-shadow-color),
inset 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * var(--_focus-in))
var(--_ring-fill, var(--ring-shadow-color));
box-shadow: var(--_focus-shadow, 0 0 #0000), var(--_shadow-resolved, 0 0 #0000);
outline: abs(var(--_focus-ring-w, var(--outline-width))) var(--outline-style) transparent;
outline-offset: calc(
var(--outline-offset) - var(--_focus-in) *
(2 * var(--outline-offset) + abs(var(--_focus-ring-w, var(--outline-width))))
);
transition: var(--default-transition);
}
@media (hover: hover) {
:where(input[role="switch"]:hover:not(:disabled)) {
background-color: var(--_bg-resolved, var(--ui-switch-track-bg--hover));
border-color: var(--_border-color-resolved, var(--ui-switch-track-border-color--hover));
}
}
:where(input[role="switch"]:checked) {
background-color: var(--_bg-resolved, var(--ui-switch-track-bg--checked));
border-color: var(--_border-color-resolved, var(--ui-switch-track-border-color--checked));
}
@media (hover: hover) {
:where(input[role="switch"]:hover:checked:not(:disabled)) {
background-color: var(--_bg-resolved, var(--ui-switch-track-bg--checked-hover));
border-color: var(
--_border-color-resolved,
var(--ui-switch-track-border-color--checked-hover)
);
}
}
:where(input[role="switch"]:focus-visible) {
border-color: var(--_border-color-resolved, var(--ui-field-border-color--focus-within));
--_ring-offset-width: var(--ring-offset-width);
--_ring-width: abs(var(--_focus-ring-w, var(--ring-width)));
outline-color: transparent;
}
}Attributes
This primitive is a composition of other primitives and utilities: it has no presets, slots, or hooks of its own. Copy its example and adapt it.
Requires: fields.
Hooks
Set a hook on :root, on a subtree, or inline on one element. A state hook (--…--hover) themes that state only; the primitive keeps its other states.
| Hook | Default | State |
|---|---|---|
--ui-switch-corner-shape | var(--ui-field-corner-shape) | — |
--ui-switch-cursor | pointer | — |
--ui-switch-h-coefficient | 1 | — |
--ui-switch-radius | var(--radius-full) | — |
--ui-switch-thumb-bg | var(--color-card) | — |
--ui-switch-thumb-bg--checked | var(--color-primary-foreground) | checked |
--ui-switch-thumb-border-color | var(--ui-field-border-color) | — |
--ui-switch-thumb-border-color--checked | transparent | checked |
--ui-switch-thumb-border-color--checked-hover | transparent | checked-hover |
--ui-switch-thumb-border-color--hover | var(--ui-field-border-color--hover) | hover |
--ui-switch-thumb-border-style | var(--ui-field-border-style) | — |
--ui-switch-thumb-border-width | var(--ui-field-border-width) | — |
--ui-switch-thumb-corner-shape | var(--ui-switch-corner-shape) | — |
--ui-switch-thumb-h | calc( var(--ui-switch-track-h) - 2 * var(--ui-switch-track-p) - 2 * var(--ui-switch-thumb-border-width) ) | — |
--ui-switch-thumb-radius | var(--ui-switch-radius) | — |
--ui-switch-thumb-scale | 1 | — |
--ui-switch-thumb-shadow | var(--shadow-xs) | — |
--ui-switch-thumb-translate | var(--ui-switch-track-p), -50% | — |
--ui-switch-thumb-w | calc( (var(--ui-switch-track-w) / 2) - var(--ui-switch-track-p) - var(--ui-switch-thumb-border-width) ) | — |
--ui-switch-track-bg | var(--color-input) | — |
--ui-switch-track-bg--checked | var(--color-primary) | checked |
--ui-switch-track-bg--checked-hover | var(--color-primary) | checked-hover |
--ui-switch-track-bg--hover | oklch(from var(--color-muted) l c h / calc(alpha * 1.5)) | hover |
--ui-switch-track-border-color | var(--ui-field-border-color) | — |
--ui-switch-track-border-color--checked | var(--ui-field-border-color--hover) | checked |
--ui-switch-track-border-color--checked-hover | var(--ui-field-border-color) | checked-hover |
--ui-switch-track-border-color--hover | var(--ui-field-border-color--hover) | hover |
--ui-switch-track-border-style | var(--ui-field-border-style) | — |
--ui-switch-track-border-width | var(--ui-field-border-width) | — |
--ui-switch-track-corner-shape | var(--ui-switch-corner-shape) | — |
--ui-switch-track-h | calc( var(--ui-switch-track-w) / 2 + var(--ui-switch-track-p) + var(--ui-switch-track-border-width) ) | — |
--ui-switch-track-p | max(calc(var(--spacing) * 0.5), calc(var(--spacing-control-min) * 0.125)) | — |
--ui-switch-track-radius | var(--ui-switch-radius) | — |
--ui-switch-track-w | max(calc(var(--spacing) * 7), calc(var(--spacing-control-min) * 1.75)) | — |
--ui-switch-w-coefficient | 1 | — |