Skip to content
kitn AI/UI

Reasoning

kai-reasoning

Opens while the model is thinking and closes when it finishes, on its own.

  • Shadow DOM
  • 1 event
  • Auto-expands while streaming
  • Markdown rendering
  • Controlled or uncontrolled

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/web-components';
await customElements.whenDefined('kai-reasoning');
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 with el.text = '...'.
  • streaming: set true while the thought arrives, and the block auto-expands; clear it and the block collapses.
  • open: leave unset for uncontrolled behaviour; set it explicitly when a parent drives the open state.
  • label overrides the default trigger text ("Reasoning"), e.g. "Thinking".

Click the trigger to expand and collapse.

Auto-expands, as it would while a model generates its chain-of-thought.

The text renders as styled markdown by default: headings, bold, code spans, paragraphs.

markdown="false" renders plain pre-formatted content, for raw log output or literal backticks.

PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
text''The reasoning text to display.
label'Reasoning'Trigger label.
open—Drive/observe the open state: `el.open = true` or the bare `open` attribute. Listen for `kai-open-change`.
defaultOpen—Initial open state on mount (uncontrolled seed).
streamingfalseWhile true, auto-expands (and re-collapses when it flips false).
markdowntrueRender `text` as markdown.
disabled—Gate the disclosure trigger: programmatic `show()/hide()/toggle()` still work, but the trigger click no longer toggles.
EventDetailNotes
The reasoning block expanded or collapsed (via the trigger, streaming auto-open, or a method).
MethodSignatureNotes
(): voidOpen it programmatically (no-op while disabled).
(): voidClose it programmatically.
(): voidFlip the open state (closes while disabled).

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

ReasoningReasoningTriggerReasoningContent