Streaming Text
Plain text that arrives in bursts, such as an LLM answer, revealed at a steady pace behind a caret.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
streaming | boolean | false | More text is coming: shows the caret and marks the element busy. Setting it back to false flushes the backlog. |
reveal | RevealMode | smooth | smooth paces the text; instant prints each chunk as it arrives. Reduced motion always behaves as instant. |
segment | RevealSegment | word | Unit released and faded in: word (the default, also right for CJK) or grapheme for a per-character look. |
value | string | — | The full text received so far, including the part not revealed yet. Setting a value that extends it appends. |
Events
| Name | Type | Description |
|---|---|---|
reveal-end | Event | Fired once per stream, when streaming is false and the display has caught up with the received text. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
text | Container of the revealed text and the caret. |
caret | Caret shown after the text while it streams or is still being revealed. Draws --c2-streaming-text__caret--content. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-streaming-text--color | color | inherit | |
--c2-streaming-text--font-family | font-family | inherit | |
--c2-streaming-text--font-size | pixel | inherit | |
--c2-streaming-text--line-height | line-height | inherit | |
--c2-streaming-text--white-space | white-space | pre-wrap | Keeps the newlines of the received text. |
--c2-streaming-text__caret--content | content | '▍' | Caret glyph. none hides the caret. |
--c2-streaming-text__caret--color | color | rgb(2, 101, 220) | |
--c2-streaming-text__caret--margin-left | pixel | 1px | |
--c2-streaming-text__caret--blink-duration | time | 1s | 0s keeps the caret solid. |
--c2-streaming-text__segment--enter-duration | time | 150ms | Fade-in of each released word. 0s turns the fade off. |
--c2-streaming-text__reveal--max-lag | time | 600ms | Longest the display may trail the received text while streaming. |
--c2-streaming-text__reveal--flush-duration | time | 300ms | Time to release the rest once streaming turns false. |