Calm motion: animations on this site only fade, with no movement
Streaming text
Text that comes in part by part, with a caret
Shows the reply of an assistant while it comes in, for example from a model that sends a few words at a time. Put it in a bubble, under a prompt input.
Basic
textis all the text that came in so far. Add each new part to it.donetells the component that the last part came in.- A caret shows at the end of the text until
done. It stops blinking when the system asks for reduced motion. - Parts often come in at an uneven rate.
paceshows the text at an even rate (letters a second) between parts, and it moves faster when it is far behind.doneshows the rest at once. With reduced motion, each part shows at once. - If
textdoes not continue the old text, for example for a new reply, the text starts over. - The text keeps its line breaks. For Markdown, use the default slot, which gets the shown text:
<template #default="{ text }"><BlessMarkdown :source="text" :lexer /></template>. - The text is a polite live region with
aria-busywhile text comes in, so screen readers wait and read the full reply, not each part.
Usage
ts
import { BlessStreamingText } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
text* | string | — | all the text that has come in so far; it grows as parts arrive |
done | boolean | — | the last part came in: the caret goes away and screen readers read the text |
pace | number | 0 | letters a second, to show the text at an even pace between parts; 0 shows each part at once |
Slots
| Name | Scope | Description |
|---|---|---|
default | { text: string; } |