Typewriter Effect

CSS-only tailwind typewriter effect with a blinking cursor.

Build interfaces faster.

Tailwind CSS
<div class="w-full max-w-xl mx-auto px-6 py-10 text-center overflow-hidden">
  <p class="text-lg md:text-2xl font-mono text-slate-800 dark:text-slate-100">
    <span class="typewriter">Build interfaces faster.</span>
  </p>
</div>
<style>
@keyframes typing { from { width: 0; } to { width: 100%; } }
@keyframes blink { 50% { border-color: transparent; } }
.typewriter { display: inline-block; overflow: hidden; white-space: nowrap; border-right: 3px solid #4f46e5; max-width: 100%; animation: typing 2.5s steps(30, end) forwards, blink 0.8s step-end infinite; }
</style>

Free to use in personal and commercial projects. No attribution required.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Fast

Quicker typing for short punchy taglines that should not keep users waiting.

Ship it today.

Tailwind CSS

Block cursor

Retro terminal block cursor for developer tools and hacker aesthetics.

Build interfaces faster.

Tailwind CSS

Emerald

Green cursor and text for eco brands and success themed headlines.

Design in the browser.

Tailwind CSS

About this typewriter effect

A tailwind typewriter effect types text character by character with a blinking cursor, like a terminal. This typewriter text tailwind snippet is pure CSS: a width animation with steps() reveals the text, and a border-right acts as the caret. It is the go-to hero accent for developer tools and portfolios.

The keyframes animate width from 0 to 100 percent in discrete steps, one step per character, so letters pop in instead of sliding. A second infinite animation blinks the caret by toggling the border color. The span needs inline-block, overflow hidden, and whitespace nowrap for the reveal to work.

Keep the typed line short; long sentences take forever at character speed and hurt readability. Respect prefers-reduced-motion by showing the full text statically. For rotating phrases, the typewriter animation css needs JavaScript to swap words between loops.

Static hero text gets skimmed like everything else on the page. Motion triggers the eye's attention reflex, which is why the typewriter effect can make a tagline land when plain text would not. It borrows terminal nostalgia: developers especially read character-by-character text as authentic. The brief wait also builds anticipation, since visitors stick around to see how the sentence ends.

A keyframe animates the element's width from 0 to 100 percent using steps(), so the text reveals in discrete jumps instead of a smooth slide. The steps count must equal the character count, including spaces, or letters pop in batches with uneven pauses. A border-right on the element acts as the caret, blinked by a second animation toggling its color. The span needs inline-block, hidden overflow, and no wrapping for the reveal to work.

Tint the caret with your brand color to make the effect feel native to the site. Keep the blink rate around 0.7 to 1 second, matching a real terminal cursor. For rotating phrases, let each phrase rest for a beat before deleting, since readers need time to finish. Cap the whole line well within mobile widths, or the no-wrap text overflows small screens.

The trap is typewriting the entire headline and looping it forever. Returning visitors watch the same sentence crawl out character by character on every visit, which turns a delight into an annoyance fast. Restrict the effect to a rotating word or short phrase inside an otherwise static headline. The static part orients instantly; the typed part provides the motion.

Where to use it

  • ✓ Developer tool landing pages
  • ✓ Portfolio hero sections
  • ✓ Terminal-style demos
  • ✓ AI chat product teasers

Customization tips

Match the steps() count to your character count for even pacing. Change the caret color to your brand, or slow the duration for a more dramatic reveal.

Design notes

When to use

The typewriter effect fits terminal aesthetics and developer tools, where text appearing character by character feels native to the medium. It can give a hero tagline a techy voice on the right product, and the blinking cursor adds personality cheaply. It works for short punchy lines that reward the wait.

What to avoid

Do not typewriter long paragraphs, because watching sentences crawl out one character at a time is agonizing. Avoid making animated text the only carrier of critical information, since some visitors and all screen readers may miss it. And never run two typewriters on one screen competing for attention.

Accessibility

Respect prefers-reduced-motion by showing the full text immediately, and provide an aria-label with the complete string so screen readers get it at once. Do not animate the page's only h1, since the heading should be available instantly.

Frequently asked questions

How does a tailwind typewriter effect work without JavaScript?

A CSS keyframe animates the element width from 0 to 100 percent using steps(), revealing one character at a time. A blinking border-right serves as the cursor. No JavaScript needed for a single phrase.

How do I loop multiple phrases in a typewriter animation?

CSS alone can only type one phrase. Use JavaScript to swap the text content and restart the animation between phrases.

Why does my typing text effect html snippet overflow on mobile?

The nowrap text can exceed small screens. Cap the font size on mobile, keep the phrase short, and add overflow-hidden to the parent container.

How do I match the steps() count to my text length?

Set the steps() value to the exact character count including spaces and punctuation, so each animation step reveals exactly one character. "Hello!" needs steps(6). A mismatched count makes the typing look uneven, with characters popping in batches or long pauses between letters.

How do I make a blinking cursor for a typewriter effect?

Add border-right to the text element and animate its color with a blink keyframes rule, toggling between the cursor color and transparent. Alternatively use a ::after pseudo-element with content "|" and an opacity animation. Keep the blink rate around 0.7 to 1 second so it feels like a real terminal.

Should typewriter effects respect prefers-reduced-motion?

Yes. Inside a @media (prefers-reduced-motion: reduce) block, disable the typing animation and show the full text statically. Typing animations can cause discomfort for people sensitive to motion, and the content is identical either way. This is a small addition that meaningfully improves accessibility.