Skip to content
synccn

Streaming Text

New

Answer text that types itself out with a caret and light Markdown, and follows a real stream smoothly as it grows.

Installation

$ pnpm dlx shadcn@latest add @synccn/streaming-text

First time in this project? Connect synccn with one command.

Usage

import { StreamingText, MarkdownLite } from "@/components/ui/streaming-text";<StreamingText text={partial} caret={!done} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

StreamingText

Text that types itself out like a model's answer, with a caret and light Markdown. Pass a growing `text` to follow a real stream; it catches up smoothly instead of jumping.

  • textrequired
    string

    The full text so far. It can keep growing while a response streams in.

  • animate
    boolean

    Default true

    Reveals the text gradually. Off shows it all at once (and so does reduced motion).

  • speed
    number

    Default 90

    Characters revealed per second.

  • caret
    boolean

    Default false

    Shows a blinking caret at the end, for example while the model is still writing.

  • onDone
    () => void

    Called once everything in `text` is visible.

  • className
    string

    Extra classes for the root element.

MarkdownLite

The small slice of Markdown chat answers use: paragraphs, "- " and "1. " lists, **bold** and `code`.

  • childrenrequired
    string

    Text with paragraphs, "- " lists, **bold** and `code`.

  • tail
    React.ReactNode

    Rendered after the last line, such as a caret.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • aria-busy is set while text is still revealing. Reduced motion shows the full text at once.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-busy
  • Respects the reduced motion setting