All components

MotionStream

Streamed text revealed at a steady pace that catches up with bursts.

WebReact NativeNumbers and text

Try it

Preparing the example…

Shortest usage

Answer.jsx
<MotionStream text={answerSoFar} initial />

<MotionStream text={answerSoFar}>
  {visible => <Markdown>{visible}</Markdown>}
</MotionStream>

What it handles for you

  • Bursts become reading: text is revealed at speed characters per second instead of in chunks.
  • A backlog speeds the reveal up so it is shown within about catchUp milliseconds.
  • Emoji, flags and combining marks are never split, and a half-received emoji waits for the rest.
  • A rewritten answer continues from the shared start instead of starting over.
  • Revealed characters go straight to the page; React renders only a few times per second.

Use it for

  • An assistant's answer in a chat.
  • A build or deploy log.
  • Live captions.

Props

PropTypeDefaultDescription
textstring—requiredThe text so far. Growing text is revealed at a steady pace; a rewrite continues from the shared start.
speednumber90Base reveal rate in characters per second.
catchUpnumber900A backlog is revealed within about this many milliseconds by speeding up.
initialbooleanfalseAlso reveal the text present on mount (otherwise it shows at once).
effect'fade' | 'none''fade'fade fades new characters in; none shows them directly.
children(visible: string) => ReactNodeA function that receives the paced text, for example to render Markdown.
aselement'span'The element to render.
onMotionComplete(text) => voidRuns whenever the reveal catches up with text.

Other props go to the rendered element, so className, style and event handlers work as usual.

Web and React Native

On the web new characters fade in (effect="fade") and are folded into plain, selectable text. A function child receives the paced string for Markdown, at most every other frame. In a hidden tab everything shows at once.

On React Native the text is a real Text and appears without a fade.

Used in these examples

Search

Type to search the documentation.