Response Stream
kai-response-stream
Animates text into view — character by character or segment by segment — for live-streamed assistant replies, accepting a plain string or an AsyncIterable<string>.
- Shadow DOM
- 2 animation modes
- Accepts AsyncIterable
- Tunable speed
- Fires kai-complete
Preview
Section titled “Preview”Set text in JavaScript (async iterables can’t be serialized to an HTML attribute). Tune mode and speed as plain attributes.
<kai-response-stream id="stream" mode="typewriter" speed="20"></kai-response-stream>
<script type="module"> import '@kitn.ai/ui/elements'; const el = document.getElementById('stream'); el.text = "Hello, this reveals one character at a time…"; el.addEventListener('kai-complete', () => console.log('done'));</script>text— string orAsyncIterable<string>. Assign after the element upgrades.mode—"typewriter"(default) streams character by character;"fade"fades in segments.speed— chars or segments per tick. Default20.as— optional wrapper element tag, e.g."p"or"span".
Examples
Section titled “Examples”Typewriter Mode
Section titled “Typewriter Mode”Fade Mode
Section titled “Fade Mode”mode="fade" fades the response in segment by segment — softer for longer, document-style answers.
Realistic Assistant Reply
Section titled “Realistic Assistant Reply”A longer message showing multi-sentence pacing. Lower speed for a deliberate reveal; higher to get users to the answer faster.
| Property | Type | Default | Notes |
|---|---|---|---|
| text | string | AsyncIterable<string> | '' | Text to stream. A string, or an `AsyncIterable<string>` (set as a JS property — async iterables can't be HTML attributes). |
| mode | "typewriter" | "fade" | 'typewriter' | Reveal animation. |
| speed | number | 20 | Characters/segments per tick. |
| as | string | — | Element tag to render as. |
Events
Section titled “Events”| Event | Detail | Notes |
|---|---|---|
| kai-complete | — | Streaming finished. |
Composed from
Section titled “Composed from”This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.
ResponseStream