ngx-prompt-kit

Response Stream

Reveals text chunk-by-chunk to mimic an LLM's streaming response. Two modes: typewriter (cumulative) or fade (per-word).

Examples

Typewriter mode

One chunk per animation frame. Speed is on a 1–100 scale.

A response stream lets you reveal generated text incrementally. The component takes a string, a mode, and a speed; it handles the rendering frames for you.

Fade mode

Each word fades in independently. Feels softer for long-form output.

A response stream lets you reveal generated text incrementally. The component takes a string, a mode, and a speed; it handles the rendering frames for you.

Live streaming (continues, doesn't restart)

Simulates an LLM streaming response: chunks arrive every ~150ms and append to the bound signal. The typewriter continues from where it left off rather than restarting on every update.

Big chunks, slow cadence

A larger paragraph-sized chunk arrives every 1000ms — closer to a real LLM that streams complete sentences. Same continuation behaviour: typewriter advances through the new content without restarting.

Adaptive pacing + finished handshake

adaptive scales the reveal speed with the backlog: it types character-by-character while caught up with the stream and accelerates when chunks arrive faster than the reveal. Set done when the source stream ends and the component emits finished exactly once after the last character is revealed — the moment to swap in your final rendering (e.g. markdown) without cutting the animation short.

Installation

Add the response-stream component (and the cn() utility) to your project.

ng generate ngx-prompt-kit:response-stream

Component API

PkResponseStream

PropTypeDefaultDescription
textStreamstring '' The full text to reveal incrementally.
mode"typewriter" | "fade" "typewriter" Reveal style.
speednumber 20 1–100. Higher = faster.
adaptiveboolean false Scale reveal speed with the backlog: types character-by-character while caught up, accelerates when the stream outpaces the reveal, never dumps.
doneboolean false Tell the component the source stream has ended. Enables the finished output.
fadeDurationnumberOverride per-segment fade duration in ms.
segmentDelaynumberOverride per-segment delay in ms.
characterChunkSizenumberOverride characters revealed per frame.
completedoutput<void>Fires each time the reveal catches up with the current textStream value.
finishedoutput<void>Fires exactly once when done is true and every received character has been revealed.
classstringExtra classes for the wrapper.