Streaming text
v0.64.0, changelogBetaA model's answer streaming token by token under a calm status row (queue, Generating with Stop, Done, Stopped, Failed), with reasoning kept apart and screen readers hearing whole sentences.
Is the charging dock in front of Patrol dog 7F3A clear?
Generating
Mostly. The dock plate is visible and free of debris, and the charging contacts are uncovered.
One cardboard box sits
Streaming
Install
npx shadcn add @syncrobotic/streaming-text Also installs: lucide-react@^1, @syncrobotic/cn, @syncrobotic/button, @syncrobotic/spinner, @syncrobotic/format-number, @syncrobotic/markdown
Overview
When to use
- A VLM's caption, count or answer about a camera frame, in a playground or on a robot's page.
- An LLM's reply in an operator's assistant, where the answer arrives over server-sent events.
- Any single answer that takes seconds and should show it is working and can be stopped.
Use something else
- Numbers arriving over time: Streaming chart.
- Lines a program writes as it runs: Log viewer.
- Work with a known end and no text to show yet: Progress or a Button's
loading. - Formatted text alone, already whole (a saved answer, a generated report): Markdown.
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Queued
Done
Stopped
Error
Reasoning
Markdown
Traditional Chinese (zh-TW)
Live
Usage rules
- For one answer that a model streams token by token: a VLM's caption, count or answer to a query, an LLM's reply. Numbers over time are
streaming-chart; lines a program writes arelog-viewer. - Append each chunk to one string and pass it as
textwith thephase. Plain text by default (blank lines start paragraphs);format="markdown"when the model writes Markdown, so it renders as headings, lists, tables and code while it streams and is read aloud without its syntax. - Set
phasefrom the request: "queued" withqueuePosition(1 is next), "streaming", then "done", "stopped" or "error" witherrorin words. Stopped and failed keep the partial text and say it is incomplete. - Give
onStopand abort the request in it, then set "stopped". GiveonRetryfor an error. Try again shows only after an error, never after Stop, so a second tap on Stop cannot start a new answer. - Pass
startedAt,firstTokenAtandfinishedAt(or the server'sdurationMsandfirstTokenMs): done says "Done in 2.4 s · first token 0.3 s". Without them it says Done. - A reasoning part goes in
reasoning, never intotext: it streams first, sits apart behind a Reasoning button, closed, and the status says Thinking until the answer starts. - Calm while it waits: grey Spinner and a word, no blinking caret, no blue. Colour only on an error's glyph and word.
- Leave
announceon "text": screen readers hear each phase once and the answer in whole sentences, at most every 5 s. "status" where the answer is read elsewhere.
Changelog
- 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
- 0.53.02026-11-27Its doc opens with its description, word for word; the code is unchanged.
- 0.51.02026-11-27Comments trimmed to what they need to say; the code is unchanged.