Streaming text
An answer writing itself out as it arrives, at an even pace with a caret.
Installation
npm i @uisatin/uiimport { StreamingText } from '@uisatin/ui/streaming-text'About 10.4 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/streaming-text.jsonAdds streaming-text.tsx to components/ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The StreamingText component renders the text received so far as a div, one span per letter (or word), and writes it out at an even pace. Letters not yet written are transparent but in the DOM, so screen readers get the whole text; the box is aria-busy while it streams.
| Prop | Type | Default |
|---|---|---|
text | string | — |
streaming | boolean | false |
speed | number | 80 |
reveal | "blur""fade""word""none" | "blur" |
caret | boolean | true |
onDone | () => void | — |
className | string | — |
ref | Ref<HTMLDivElement> | — |
...props | ComponentProps<'div'>Other attributes go to <div> | — |
Accessibility
The whole text received is in the DOM from the start (letters not yet written are only transparent), so screen readers get it at once, and the box is aria-busy while it streams. It is not a live region, so arriving text isn’t read out on its own. The caret is hidden. Under reduced motion it shows everything received straight away.
Something wrong or missing on this page?
Report a problemSuggest an improvement