package page→ /design/shtukbase-ui-html/components/primitive/switch/switch.css
pages/design/shtukbase-ui-html/components/primitive/switch/switch.css
25 lines, 1.9 KB. Open as is (in a project other files lie next to it; they may be missing here).
- /* switch: the shadcn anatomy; the thumb slides inside the track, the switch itself keeps its place. */
- .switch {
- position: relative; display: inline-flex; align-items: center; flex: none; box-sizing: border-box;
- width: 32px; height: 18px; padding: 2px; margin: 0; border: 0; outline: none; cursor: pointer;
- border-radius: calc(var(--radius) * 100);
- background: color-mix(in srgb, var(--muted-foreground) 32%, var(--background));
- box-shadow: 0 0 0 0 transparent;
- transition: background-color var(--sb-dur, .18s) var(--sb-ease, ease), box-shadow var(--sb-dur, .18s) var(--sb-ease, ease);
- }
- .switch-thumb {
- display: block; width: 14px; height: 14px; border-radius: calc(var(--radius) * 100); pointer-events: none;
- background: var(--background);
- box-shadow: 0 0 0 .5px color-mix(in srgb, var(--foreground) 10%, transparent), 0 1px 2px color-mix(in srgb, var(--foreground) 16%, transparent);
- transition: transform var(--sb-dur, .18s) var(--sb-ease, ease);
- }
- .switch:is([data-checked], [aria-checked="true"]) { background: var(--primary); }
- .switch:is([data-checked], [aria-checked="true"]) .switch-thumb { transform: translateX(14px); }
- .switch:is(:hover, [data-hover]):not(:disabled) { background: color-mix(in srgb, var(--muted-foreground) 42%, var(--background)); }
- .switch:is([data-checked], [aria-checked="true"]):is(:hover, [data-hover]):not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--foreground)); }
- .switch:is(:focus-visible, [data-focus]) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent); }
- .switch[data-size="sm"] { width: 26px; height: 15px; }
- .switch[data-size="sm"] .switch-thumb { width: 11px; height: 11px; }
- .switch[data-size="sm"]:is([data-checked], [aria-checked="true"]) .switch-thumb { transform: translateX(11px); }
- .switch:disabled { opacity: .5; cursor: not-allowed; }
- @media (prefers-reduced-motion: reduce) { .switch, .switch-thumb { transition: none; } }