Reasoning
kai-reasoning
A collapsible thinking block that auto-expands while the model’s thought streams in and collapses when streaming stops — no wiring required.
- Shadow DOM
- 1 event
- Auto-expands while streaming
- Markdown rendering
- Controlled or uncontrolled
Preview
Section titled “Preview”Set text in JavaScript; toggle streaming to drive the auto-expand/collapse behaviour:
<kai-reasoning id="reason" label="Reasoning"></kai-reasoning>
<script type="module"> import '@kitn.ai/ui/elements';
const reason = document.getElementById('reason'); reason.text = 'First I parse the request, then I plan the steps, then I execute.';
// Set while thought arrives; clear when stream ends. // reason.streaming = true;
reason.addEventListener('kai-open-change', (e) => { console.log('open:', e.detail.open); });</script>text— assign it withel.text = '...'.streaming— settruewhile the thought arrives; the block auto-expands. Clear it when done; the block collapses.open— leave unset for uncontrolled behaviour; set explicitly when a parent needs to drive the open state.labeloverrides the default trigger text ("Reasoning") — e.g."Thinking"or"Chain of thought".
Examples
Section titled “Examples”Default
Section titled “Default”A collapsed block with uncontrolled open state. Click the trigger to expand and collapse.
Streaming
Section titled “Streaming”streaming set to true auto-expands the block immediately, as it would while a model generates its chain-of-thought.
Custom Label
Section titled “Custom Label”Override the trigger label with the label attribute to match your product’s terminology.
Markdown Rendering
Section titled “Markdown Rendering”With markdown enabled (default), the text renders as styled markdown — headings, bold, code spans, and paragraphs.
Markdown Disabled
Section titled “Markdown Disabled”markdown="false" renders the text as plain pre-formatted content — useful for raw log output or content with literal backticks.
| Property | Type | Default | Notes |
|---|---|---|---|
| text | string | '' | The reasoning text to display. |
| label | string | 'Reasoning' | Trigger label. |
| open | boolean | — | Controlled open state — set as a property (`el.open = true`). Omit for uncontrolled (the trigger toggles it). |
| streaming | boolean | false | While true, auto-expands (and re-collapses when it flips false). |
| markdown | boolean | true | Render `text` as markdown. |
Events
Section titled “Events”| Event | Detail | Notes |
|---|---|---|
| kai-open-change | | Open state changed (via the trigger or streaming auto-open). |
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.