Skip to content
kitn AI/UI

Chain Of Thought

kai-chain-of-thought

Shows the plan behind an answer, with the detail hidden until the reader asks for it.

  • Shadow DOM
  • Property-driven API
  • Declarative kai-step children
  • Expandable detail per step
  • Prop + child steps merge

Set steps in JavaScript — it’s an array, so it can’t be an HTML attribute:

<kai-chain-of-thought id="cot"></kai-chain-of-thought>
<script type="module">
import '@kitn.ai/ui/web-components';
document.getElementById('cot').steps = [
{ label: 'Understand the request', content: 'The user wants composable web components.' },
{ label: 'Design the API', content: 'Route 1: variant + flags; rich data via properties.' },
{ label: 'Build & verify' },
];
</script>
  • Each item needs a label string; add content to make the step expandable.
  • Declarative alternative — author steps as <kai-step> children; label becomes the heading, textContent becomes the collapsible detail. Mix both: property items render first, then <kai-step> children append after.
<kai-chain-of-thought>
<kai-step label="Understand the request">The user wants composable web components.</kai-step>
<kai-step label="Design the API">Route 1: variant + flags; rich data via properties.</kai-step>
<kai-step label="Build &amp; verify"></kai-step>
</kai-chain-of-thought>
Child elementAttributesText contentNotes
labelstep-id
YesParse a single light-DOM `<kai-step>` element into a `Step` descriptor. Attribute mapping: - `label` → Step.label (the always-visible heading) - `step-id` → Step.id (optional stable open-set key) - textContent → Step.content (optional expandable detail)

Every step has expandable detail, with no label-only summary.

PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
steps[]The reasoning steps. JS property (array); omit to pass `<kai-step>` light-DOM children instead.
type—Open mode: `'multiple'` (default, any number of steps open at once) or `'single'` (at most one open; opening a step closes the others).
value—Controlled open step key(s): a string in `single` mode, a string array in `multiple`. JS property.
defaultValue—Uncontrolled INITIAL open step key(s), seeding which steps render expanded. Ignored once `value` is provided. Set as a JS property.
MethodSignatureNotes
(index?: number): voidOpen one step's detail by index, or ALL steps when called with no arg. In `single` mode opening one step closes the others (expand-all keeps the last).
(index?: number): voidClose one step's detail by index, or ALL steps when called with no arg.
(index?: number): voidFlip one step's open state by index.

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

ChainOfThoughtAccordion