AI CSS Animations

Terminal Spinner Text

The braille dot spinner from command line tools, cycling beside an install step while package names tick past below it. Both are columns of text that step up inside a one-line window.

Also known as: cli spinner css, braille spinner animation, npm install spinner.

✔ Resolved 214 packages

Installing dependencies

HTML

<div class="txt-terminal-spinner-text">
  <p class="txt-terminal-spinner-text-done"><b>✔</b> Resolved 214 packages</p>
  <p><span class="txt-terminal-spinner-text-spin" aria-hidden="true"><span>⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏</span></span> Installing dependencies</p>
  <p class="txt-terminal-spinner-text-pkg" aria-hidden="true">  └ <span class="txt-terminal-spinner-text-names"><span>react-dom</span><span>esbuild</span><span>postcss</span><span>zod</span><span>vite</span><span>typescript</span><span>eslint</span></span></p>
</div>

CSS

.txt-terminal-spinner-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: calc(var(--txt-size, 32px) * 0.6);
  font-weight: 500;
  line-height: 1.6;
  text-align: left;}
.txt-terminal-spinner-text p {
  margin: 0;
  white-space: pre;
}
.txt-terminal-spinner-text-done {
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.txt-terminal-spinner-text b {
  font-weight: inherit;
  color: var(--c);
}
.txt-terminal-spinner-text-spin {
  display: inline-block;
  vertical-align: top;
  width: 1ch;
  height: 1.6em;
  overflow: hidden;
  /* regular weight: heavier weights fall back to a braille font that also draws the empty dots */
  font-weight: 400;
  color: var(--c);
}
/* ten frames, one per line of a 1ch-wide column */
.txt-terminal-spinner-text-spin span {
  display: block;
  width: 1ch;
  word-break: break-all;
  white-space: normal;
  animation: txt-terminal-spinner-text-frames 0.8s steps(10) infinite;
}
.txt-terminal-spinner-text-pkg {
  color: color-mix(in srgb, currentColor 45%, transparent);
}
.txt-terminal-spinner-text-names {
  display: inline-block;
  vertical-align: top;
  height: 1.6em;
  overflow: hidden;
}
/* seven names, one per line; steps(7) shows each in turn and wraps to the first */
.txt-terminal-spinner-text-names span {
  display: block;
  animation: txt-terminal-spinner-text-names 2.8s steps(7) infinite;
}
@keyframes txt-terminal-spinner-text-frames {
  to { transform: translateY(-16em); }
}
@keyframes txt-terminal-spinner-text-names {
  to { transform: translateY(-11.2em); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-terminal-spinner-text, .txt-terminal-spinner-text *, .txt-terminal-spinner-text::before, .txt-terminal-spinner-text::after, .txt-terminal-spinner-text *::before, .txt-terminal-spinner-text *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • 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 text animations