ShtukbaseStandard
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).

  1. /* switch: the shadcn anatomy; the thumb slides inside the track, the switch itself keeps its place. */
  2. .switch {
  3. position: relative; display: inline-flex; align-items: center; flex: none; box-sizing: border-box;
  4. width: 32px; height: 18px; padding: 2px; margin: 0; border: 0; outline: none; cursor: pointer;
  5. border-radius: calc(var(--radius) * 100);
  6. background: color-mix(in srgb, var(--muted-foreground) 32%, var(--background));
  7. box-shadow: 0 0 0 0 transparent;
  8. transition: background-color var(--sb-dur, .18s) var(--sb-ease, ease), box-shadow var(--sb-dur, .18s) var(--sb-ease, ease);
  9. }
  10. .switch-thumb {
  11. display: block; width: 14px; height: 14px; border-radius: calc(var(--radius) * 100); pointer-events: none;
  12. background: var(--background);
  13. 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);
  14. transition: transform var(--sb-dur, .18s) var(--sb-ease, ease);
  15. }
  16. .switch:is([data-checked], [aria-checked="true"]) { background: var(--primary); }
  17. .switch:is([data-checked], [aria-checked="true"]) .switch-thumb { transform: translateX(14px); }
  18. .switch:is(:hover, [data-hover]):not(:disabled) { background: color-mix(in srgb, var(--muted-foreground) 42%, var(--background)); }
  19. .switch:is([data-checked], [aria-checked="true"]):is(:hover, [data-hover]):not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--foreground)); }
  20. .switch:is(:focus-visible, [data-focus]) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent); }
  21. .switch[data-size="sm"] { width: 26px; height: 15px; }
  22. .switch[data-size="sm"] .switch-thumb { width: 11px; height: 11px; }
  23. .switch[data-size="sm"]:is([data-checked], [aria-checked="true"]) .switch-thumb { transform: translateX(11px); }
  24. .switch:disabled { opacity: .5; cursor: not-allowed; }
  25. @media (prefers-reduced-motion: reduce) { .switch, .switch-thumb { transition: none; } }