Back to the library

Stubborn toggle, hairline

Variant: Hairline

This is the locked-switch refusal at its lightest. The knob moves only a fifth of its width, the ring is a faint 1px line, and the lock glyph rests almost out of view. Use it in dense settings lists where many rows are locked and a heavier response would read as an error. Timing is the same as Standard, so only the size of the motion changes.

togglelockedfeedbacksubtlesettings

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Stubborn toggle — Hairline</title>
<style>
:root {
  /* Neutrals — fixed, never remixed. */
  --ivory: #faf9f5;
  --paper: #ffffff;
  --oat: #e3dacc;
  --slate: #141413;

  /* Knobs — the remix API. A knob exists iff declared here and used below. */
  --hue: 38.8;
  --lift: 0;
  --chroma: 1;
  --round: 1; /* include ONLY if at least one border-radius is wrapped below */
  --speed: 1;

  /* Accents — derived from the knobs with the family's offsets baked in,
     so one hue roll moves them together. Defaults reproduce the original hex
     (#d97757 / #b85c3e / #788c5d / #b04a3f). */
  --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
  --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
  --olive: oklch(calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3));
  --rust: oklch(calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3));

  /* Clock — every duration in the document runs off --t. */
  --cycle: 3.2s; /* the authored master loop */
  --t: calc(var(--cycle) / var(--speed));

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1); /* include only if used */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); /* include only if used */

  --_shadow: color-mix(in oklch, var(--slate) 22%, transparent);
  --_travel: 18%;
  --_squash: 0.015;
  --_stroke: 1.8;
  --_ring: 0.28;
  --_ring-w: 1px;
  --_ring-scale: 1.06;
  --_tap: 0.14;
  --_lock-rest: 0.3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--ivory);
  color: var(--slate);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.card {
  width: min(360px, 88vw);
  background: var(--paper);
  border: 1px solid var(--oat);
  border-radius: calc(14px * var(--round));
  padding: clamp(4px, 1.5vw, 8px) clamp(14px, 4vw, 20px);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 4vw, 20px);
  padding: clamp(10px, 3vw, 14px) 0;
}
.row + .row { border-top: 1px solid var(--oat); }

.label { display: grid; gap: 2px; min-width: 0; }
.title { font-size: clamp(14px, 3.8vw, 15px); font-weight: 600; }
.hint { font-size: clamp(12px, 3.2vw, 13px); opacity: 0.6; }

.track {
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--oat);
}
.track.on { background: var(--clay); }

.thumb { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; }
.track.on .thumb { transform: translateX(22px); }

.dot {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: var(--clay);
  opacity: 0;
}

.knob {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px var(--_shadow);
  display: grid;
  place-items: center;
}

.lock {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--clay-d);
  stroke-width: var(--_stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: var(--_lock-rest);
}

.track.locked::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: var(--_ring-w) solid var(--clay);
  opacity: 0;
  pointer-events: none;
}

.locked .thumb { animation: strain var(--t) infinite; }
.locked .knob { animation: squash var(--t) infinite; }
.locked .dot { animation: press var(--t) infinite; }
.locked .lock { animation: lock var(--t) infinite; }
.track.locked::after { animation: refuse var(--t) infinite; }
.row-locked .hint { animation: hint var(--t) infinite; }

/* Push 14→22% (256ms), stall 96ms against the stop, release at 25%: snap home in 160ms. */
@keyframes strain {
  0%, 14% { transform: translateX(0); animation-timing-function: var(--ease-in-out); }
  22% { transform: translateX(var(--_travel)); animation-timing-function: linear; }
  25% { transform: translateX(var(--_travel)); animation-timing-function: var(--ease-out); }
  30%, 100% { transform: translateX(0); }
}

@keyframes squash {
  0%, 14% { transform: scale(1); animation-timing-function: var(--ease-in-out); }
  22% { transform: scale(calc(1 + var(--_squash)), calc(1 - var(--_squash))); animation-timing-function: linear; }
  25% { transform: scale(calc(1 + var(--_squash)), calc(1 - var(--_squash))); animation-timing-function: var(--ease-out); }
  30%, 100% { transform: scale(1); }
}

@keyframes press {
  0%, 10% { opacity: 0; transform: scale(0.9); animation-timing-function: var(--ease-out); }
  14% { opacity: var(--_tap); transform: scale(1); animation-timing-function: linear; }
  25% { opacity: var(--_tap); transform: scale(1); animation-timing-function: var(--ease-out); }
  29%, 100% { opacity: 0; transform: scale(1.04); }
}

@keyframes refuse {
  0%, 24% { opacity: 0; transform: scale(0.96); animation-timing-function: var(--ease-out); }
  28% { opacity: var(--_ring); transform: scale(1); animation-timing-function: var(--ease-out); }
  36%, 100% { opacity: 0; transform: scale(var(--_ring-scale)); }
}

@keyframes lock {
  0%, 22% { opacity: var(--_lock-rest); animation-timing-function: ease; }
  26% { opacity: 1; }
  50% { opacity: 1; animation-timing-function: ease; }
  60%, 100% { opacity: var(--_lock-rest); }
}

@keyframes hint {
  0%, 24% { opacity: 0.6; animation-timing-function: ease; }
  28% { opacity: 1; }
  50% { opacity: 1; animation-timing-function: ease; }
  60%, 100% { opacity: 0.6; }
}

@keyframes press-soft {
  0%, 10% { opacity: 0; }
  14% { opacity: var(--_tap); }
  25% { opacity: var(--_tap); }
  29%, 100% { opacity: 0; }
}

@keyframes refuse-soft {
  0%, 24% { opacity: 0; }
  30% { opacity: calc(var(--_ring) * 0.7); }
  44%, 100% { opacity: 0; }
}

@media (max-width: 380px) {
  .row { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .locked .thumb,
  .locked .knob { animation: none; }
  .locked .dot { animation: press-soft calc(var(--t) * 2) infinite; }
  .track.locked::after { transform: scale(1); animation: refuse-soft calc(var(--t) * 2) infinite; }
  .locked .lock,
  .row-locked .hint { animation-duration: calc(var(--t) * 2); }
}
</style>
</head>
<body>
  <div class="card">
    <div class="row">
      <div class="label">
        <span class="title">Notifications</span>
        <span class="hint">Email and push</span>
      </div>
      <div class="track on" role="switch" aria-checked="true" aria-label="Notifications">
        <div class="thumb"><span class="knob"></span></div>
      </div>
    </div>
    <div class="row row-locked">
      <div class="label">
        <span class="title">Auto-update</span>
        <span class="hint">Locked by your admin</span>
      </div>
      <div class="track locked" role="switch" aria-checked="false" aria-disabled="true" aria-label="Auto-update, locked">
        <div class="thumb">
          <span class="dot"></span>
          <span class="knob">
            <svg class="lock" viewBox="0 0 24 24" aria-hidden="true">
              <rect x="5" y="11" width="14" height="10" rx="2" />
              <path d="M8 11V8a4 4 0 0 1 8 0v3" />
            </svg>
          </span>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

The variant family

Same idea, one axis moved. Compare them side by side before you commit.