AI CSS Animations

Text with Blinking Cursor

A static line of text followed by a block cursor that blinks, as at a terminal prompt. Pairs with any typing effect, or stands alone as a 'waiting for input' cue.

Also known as: terminal prompt, command line cursor.

$ npm run build

HTML

<div class="txt-blinking-cursor-text">$ npm run build<span aria-hidden="true"></span></div>

CSS

.txt-blinking-cursor-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;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500;
  color: var(--c);}
.txt-blinking-cursor-text span {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.15em;
  vertical-align: text-bottom;
  background: var(--c);
  animation: txt-blinking-cursor-text-blink 1s steps(2, start) infinite;
}
@keyframes txt-blinking-cursor-text-blink {
  to { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .txt-blinking-cursor-text, .txt-blinking-cursor-text *, .txt-blinking-cursor-text::before, .txt-blinking-cursor-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