Typewriter

Text that appears character by character with a blinking cursor. Supports looping phrases, cursor styles, speeds, and colors.

This component requires softui.js for interactive behavior.

Default

Welcome to SoftUI, a neumorphic CSS library.

<p style="font-size:22px;font-weight:700;color:var(--sui-text);">
  <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter>Welcome to SoftUI, a neumorphic CSS library.</span>
</p>

<!-- Types out the text content character by character -->
<!-- sui-typewriter-cursor adds the blinking cursor -->

Loop

I love

npm install

<div style="display:flex;flex-direction:column;gap:20px;">
  <p style="font-size:22px;font-weight:700;color:var(--sui-text);">
    I love
    <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter data-words="building websites|writing CSS|creating components|open source" data-loop></span>
  </p>
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    npm install
    <span class="sui-typewriter sui-typewriter-cursor sui-typewriter-primary" data-sui-typewriter data-words="softui-css|react|vue|svelte" data-loop></span>
  </p>
</div>

<!-- data-words: pipe-separated phrases to cycle through -->
<!-- data-loop: types, deletes, types next phrase, repeats -->

Cursor Styles

Line cursor:

Block cursor:

Underscore cursor:

<div style="display:flex;flex-direction:column;gap:20px;">
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    Line cursor:
    <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter data-words="default cursor style" data-speed="60"></span>
  </p>
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    Block cursor:
    <span class="sui-typewriter sui-typewriter-cursor-block" data-sui-typewriter data-words="block cursor style" data-speed="60"></span>
  </p>
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    Underscore cursor:
    <span class="sui-typewriter sui-typewriter-cursor-underscore" data-sui-typewriter data-words="underscore cursor style" data-speed="60"></span>
  </p>
</div>

Speeds

Slow (120ms):

Default (80ms):

Fast (30ms):

<div style="display:flex;flex-direction:column;gap:20px;">
  <p style="font-size:18px;font-weight:600;color:var(--sui-text);">
    Slow (120ms):
    <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter data-words="This types slowly...|Notice the pace?" data-speed="120" data-loop></span>
  </p>
  <p style="font-size:18px;font-weight:600;color:var(--sui-text);">
    Default (80ms):
    <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter data-words="This is the default speed.|A good balance." data-speed="80" data-loop></span>
  </p>
  <p style="font-size:18px;font-weight:600;color:var(--sui-text);">
    Fast (30ms):
    <span class="sui-typewriter sui-typewriter-cursor" data-sui-typewriter data-words="This types really fast!|Blink and you miss it." data-speed="30" data-loop></span>
  </p>
</div>

<!-- data-speed: ms per character (default 80) -->
<!-- data-delete-speed: ms per character when deleting (default 40) -->
<!-- data-pause: ms to pause before deleting (default 1500) -->

With Colors

Deploy to

Status:

Error:

<div style="display:flex;flex-direction:column;gap:20px;">
  <p style="font-size:22px;font-weight:700;color:var(--sui-text);">
    Deploy to
    <span class="sui-typewriter sui-typewriter-cursor sui-typewriter-primary" data-sui-typewriter data-words="production|staging|preview" data-loop></span>
  </p>
  <p style="font-size:22px;font-weight:700;color:var(--sui-text);">
    Status:
    <span class="sui-typewriter sui-typewriter-cursor-block sui-typewriter-success" data-sui-typewriter data-words="All systems operational" data-speed="50"></span>
  </p>
  <p style="font-size:22px;font-weight:700;color:var(--sui-text);">
    Error:
    <span class="sui-typewriter sui-typewriter-cursor sui-typewriter-danger" data-sui-typewriter data-words="Connection refused|Timeout exceeded|404 Not Found" data-loop data-pause="2000"></span>
  </p>
</div>

<!-- Color classes: sui-typewriter-primary, success, danger, warning, info -->

Reserve Space

Add data-reserve to hold the width of the longest phrase.

Ship faster with SoftUI.

Status: Building — this sentence stays put.

<div style="display:flex;flex-direction:column;gap:20px;">
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    Ship <span class="sui-typewriter sui-typewriter-cursor sui-typewriter-primary" data-sui-typewriter data-reserve data-words="faster|smaller bundles|accessible interfaces" data-loop>faster</span> with SoftUI.
  </p>
  <p style="font-size:20px;font-weight:600;color:var(--sui-text);">
    Status: <span class="sui-typewriter sui-typewriter-cursor-block" data-sui-typewriter data-reserve data-words="Building|Testing|Deploying|Live" data-loop data-sr-text="Build status">Building</span> — this sentence stays put.
  </p>
</div>

<!-- data-reserve: width of the longest phrase, so nothing after it reflows -->
<!-- Text inside a data-words element is shown first, then typed over
     (if it matches the first phrase, typing continues from there) -->
<!-- data-sr-text: what screen readers hear (default: all phrases, comma-separated) -->
<!-- prefers-reduced-motion: static text, no typing
     (existing text or first phrase with data-loop, last phrase without) -->

Reference

Attribute / Class / SettingDescription
data-sui-typewriterTurns the element into a typewriter. Without data-words it types its own text once.
data-wordsPhrases separated by |. Text already inside the element (e.g. server-rendered) shows first, then is typed over.
data-loopTypes, deletes and moves to the next phrase, forever. Without it, typing stops on the last phrase.
data-speedMilliseconds per typed character (default 80).
data-delete-speedMilliseconds per deleted character (default 40).
data-pauseMilliseconds to wait before deleting a finished phrase (default 1500).
data-reserveSizes to the longest phrase so the text after it never shifts.
data-sr-textWhat screen readers hear (default: all phrases once).
sui-typewriter-cursor, -cursor-block, -cursor-underscoreLine, block or underscore blinking cursor.
sui-typewriter-primary, -success, -danger, -warning, -infoText colour.
prefers-reduced-motionStatic text, no typing: the existing text or first phrase with data-loop, the last phrase without. Plain-text mode shows the full text.

Delete this item?

This action cannot be undone. This will permanently delete the item and remove all associated data.