Code

<script src="/stream-text.free.js" defer></script>

<!-- play a fixed text -->
<stream-text simulate="8" theme="light">
  Your flight lands at 14:20. I moved the pickup to 15:00 and told the hotel you will arrive early.
</stream-text>

<!-- or feed it a real stream -->
<stream-text id="answer" streaming></stream-text>
<script>
  // for each chunk: answer.text += chunk;  when done: answer.removeAttribute('streaming')
</script>

In context

Assistant reply

Mint, faster Pro

Install · Free Web Component

One file, no dependencies. Aurora preset, every other option included. Host it yourself so your visitors never load anything from our servers.

1. Install with one command — or download the file
shadcn CLI · React
npx shadcn@latest add https://www.ui-design.co/r/stream-text.json
2. Load it and use the element
HTML
<script src="/stream-text.free.js" defer></script>

<!-- play a fixed text -->
<stream-text simulate="8" theme="light">
  Your flight lands at 14:20. I moved the pickup to 15:00 and told the hotel you will arrive early.
</stream-text>

<!-- or feed it a real stream -->
<stream-text id="answer" streaming></stream-text>
<script>
  // for each chunk: answer.text += chunk;  when done: answer.removeAttribute('streaming')
</script>
3. React + TypeScript (optional)

The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:

TypeScript
// stream-text.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'stream-text': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      text?: string;
      streaming?: boolean | '';
      simulate?: number | string;
      loop?: boolean | '';
      theme?: 'light' | 'dark';
    };
  }
}

Pro · React + TypeScript Pro

One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.

  • React component with TypeScript types and a replay() ref
  • Sunset, Mint and Mono tints
  • The vanilla Web Component with every tint, a demo page, README and license

Attributes & props

NameTypeDefaultDescription
text string''The text so far. Append to it and only the new words animate in; replace it and it starts over.
streaming booleanfalseShows the glowing bead: more is coming.
simulate number (words/s)0Plays a fixed text by itself at this speed. In HTML the text can be the element’s content.
loop booleanfalseWith simulate: starts over after a pause.
theme 'light' | 'dark''light'Ink colour the words cool to.
tint Pro'aurora' | 'sunset' | 'mint' | 'mono''aurora'Colours of arriving words and the bead. Free build ships Aurora only.

It inherits font, size and line height from where you put it. Screen readers get the whole text as one label, not word by word. Text that is already there when it mounts appears without the entrance, so a restored chat does not replay. Reduced motion shows words at once with no blur. It uses no WebGL and no dependencies.

More components