AI CSS Animations

Thinking Effort Selector

A Low, Medium, High thinking effort control: the thumb glides between choices, the thinking budget bar stretches from 4k to 32k tokens with a live counter, and the hint under it rolls to match.

Also known as: reasoning effort toggle, thinking budget slider, low medium high selector.

Thinking effort

HTML

<div class="aia-effort-level-selector" role="status" aria-label="Thinking effort selector moving between Low, Medium and High">
  <div class="aia-effort-level-selector-head"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3.5l1.9 5.1 5.1 1.9-5.1 1.9L12 17.5l-1.9-5.1L5 10.5l5.1-1.9z"/></svg><b>Thinking effort</b><span class="aia-effort-level-selector-tok" aria-hidden="true"></span></div>
  <div class="aia-effort-level-selector-seg" aria-hidden="true">
    <i class="aia-effort-level-selector-thumb"></i>
    <span style="--k: 0">Low</span><span style="--k: 1">Medium</span><span style="--k: 2">High</span>
  </div>
  <div class="aia-effort-level-selector-track" aria-hidden="true"><i></i></div>
  <div class="aia-effort-level-selector-hint" aria-hidden="true"><span style="--k: 0">Quick answers, lowest latency</span><span style="--k: 1">Balanced depth and speed</span><span style="--k: 2">Deep reasoning for hard problems</span></div>
</div>

CSS

@property --aia-effort-level-selector-e {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --aia-effort-level-selector-k {
  syntax: "<integer>";
  inherits: false;
  initial-value: 4;
}
.aia-effort-level-selector {
  --c: var(--aia-color, #7c5cff);
  font-size: var(--aia-size, 16px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
  position: relative;
  box-sizing: border-box;
  padding: 0.9em 1em;
  border-radius: 0.9em;
  background: color-mix(in srgb, currentColor 3%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 11%, transparent), 0 0.1em 0.2em color-mix(in srgb, currentColor 4%, transparent), 0 0.9em 2em -1.1em rgb(0 0 0 / 0.3);
  --d: 8s;
  --e: var(--aia-effort-level-selector-e);
  --budget: calc(4 + 12 * min(var(--e), 1) + 16 * max(var(--e) - 1, 0));
  width: 20em;
  padding: 0.85em 0.95em 0.8em;
  animation: aia-effort-level-selector-clock var(--d) cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.aia-effort-level-selector-head {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82em;
}
.aia-effort-level-selector-head svg {
  width: 1.1em;
  height: 1.1em;
  color: var(--c);
  fill: currentColor;
  stroke: none;
  transform: rotate(calc(var(--e) * 45deg)) scale(calc(0.85 + var(--e) * 0.12));
}
.aia-effort-level-selector-head b {
  margin-right: auto;
  font-weight: 600;
}
.aia-effort-level-selector-tok {
  color: color-mix(in srgb, currentColor 55%, transparent);
  font: 500 0.92em ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  --aia-effort-level-selector-k: var(--budget);
  counter-reset: k var(--aia-effort-level-selector-k);
}
.aia-effort-level-selector-tok::before { content: counter(k) "k tokens"; }
.aia-effort-level-selector-seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0.6em 0 0.75em;
  padding: 0.22em;
  border-radius: 0.7em;
  background: color-mix(in srgb, currentColor 6%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 8%, transparent);
}
.aia-effort-level-selector-thumb {
  position: absolute;
  left: 0.22em;
  top: 0.22em;
  bottom: 0.22em;
  width: calc((100% - 0.44em) / 3);
  border-radius: 0.5em;
  background: var(--c);
  box-shadow: 0 0.3em 0.8em -0.3em color-mix(in srgb, var(--c) 80%, transparent);
  transform: translateX(calc(var(--e) * 100%));
}
.aia-effort-level-selector-seg span {
  --on: clamp(0, 1 - max(var(--e) - var(--k), var(--k) - var(--e)) * 1.6, 1);
  position: relative;
  padding: 0.4em 0;
  color: color-mix(in srgb, #fff calc(var(--on) * 100%), color-mix(in srgb, currentColor 58%, transparent));
  font-size: 0.8em;
  font-weight: 600;
  text-align: center;
}
.aia-effort-level-selector-track {
  position: relative;
  height: 0.45em;
  border-radius: 999em;
  background:
    linear-gradient(90deg, transparent calc(12.5% - 1px), color-mix(in srgb, currentColor 22%, transparent) 0 12.5%, transparent 0 calc(50% - 1px), color-mix(in srgb, currentColor 22%, transparent) 0 50%, transparent 0) ,
    color-mix(in srgb, currentColor 8%, transparent);
}
.aia-effort-level-selector-track i {
  position: absolute;
  inset: 0;
  width: calc(var(--budget) / 32 * 100%);
  overflow: hidden;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
}
.aia-effort-level-selector-track i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.55), transparent) 0 0 / 40% 100% no-repeat;
  animation: aia-effort-level-selector-glint 1.6s ease-in-out infinite;
}
.aia-effort-level-selector-hint {
  display: grid;
  margin-top: 0.5em;
  color: color-mix(in srgb, currentColor 55%, transparent);
  font-size: 0.74em;
}
.aia-effort-level-selector-hint span {
  --on: clamp(0, 1 - max(var(--e) - var(--k), var(--k) - var(--e)) * 2, 1);
  grid-area: 1 / 1;
  opacity: var(--on);
  transform: translateY(calc((var(--k) - var(--e)) * 0.6em));
}
@keyframes aia-effort-level-selector-clock {
  0%, 18% { --aia-effort-level-selector-e: 0; }
  28%, 46% { --aia-effort-level-selector-e: 1; }
  56%, 82% { --aia-effort-level-selector-e: 2; }
  94%, 100% { --aia-effort-level-selector-e: 0; }
}
@keyframes aia-effort-level-selector-glint {
  from { background-position: -50% 0; }
  to { background-position: 160% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .aia-effort-level-selector {
    animation: none;
    --aia-effort-level-selector-e: 1;
  }
  .aia-effort-level-selector-track i::after { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .aia-effort-level-selector, .aia-effort-level-selector *, .aia-effort-level-selector::before, .aia-effort-level-selector::after, .aia-effort-level-selector *::before, .aia-effort-level-selector *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --aia-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --aia-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar ai animations