Use with the AI SDK
Which Kokonut UI component draws each part of an AI SDK message, from text and sources to tool calls that stream, wait for approval or return a card.
Kokonut UI's AI components take the AI SDK's shapes as they come. Tool parts keep their state names, streams can be passed straight in, and a tool's output is the data a card needs. Every component also plays a demo when you leave its data out, so you can place it first and wire it after.
Message parts
useChat() gives you messages, and each message has parts. Draw each part with the component on its row.
| AI SDK part | Component | What you pass |
|---|---|---|
text, before the first token | AI Text Loading | Show it while status is submitted; showElapsed adds the seconds |
source-url | AI Inline Citations | The text as parts, each part's cite ids, and the sources as sources |
tool-*, read-only tools (search, fetch) | AI Tool Calls | One row per part; its state is the part's state |
tool-* with needsApproval | AI Tool Approval | The calls, and onRespond that calls addToolApprovalResponse |
tool-* for sub-agents | AI Agent Lanes | A lane per sub-agent, a step from input-available to output-available |
Tools that return a card
Give the model a tool, and pass its output (or its streaming input) to the card.
| Tool | Component | Draw it when |
|---|---|---|
prepare_order | AI Checkout | The order is ready to pay |
track_order | AI Order Status | Call it again, or stream data parts, for fresh positions |
find_times | AI Schedule | The free slots from both calendars are back |
draft_email | AI Send | While its input streams, so the draft writes itself in |
create_post | AI Post | Poll or stream to move rows from scheduled to posted |
save_memory | AI Memory | The model decides to keep or replace a fact |
handoff_to_human | AI Handoff | Its part reaches output-available with your ticket id |
| A tool that needs an app | AI Connect | The call stops for a missing connection, then retries |
Streams
| Stream | Component | Prop |
|---|---|---|
streamText(...).textStream for a rewrite | AI Inline Edit | rewrite returns the stream |
| A coding agent's file edits | AI Diff Review | files, and onDecision per file |
| Token log probabilities | AI Token Alternatives | slots with what else the model weighed, and compose to write the rest after a pick |
The prompt box
AI Input Selector calls onSubmit with the text, the model and { effort, files, signal }. Call sendMessage there and pass stop as onStop; return a Promise and the Stop key shows until it settles. AI Input Search works the same way through onSearch, with an onSource callback for each source-url part as it arrives.
AI Message Queue holds follow-ups typed while a run is going. Its respond returns a stream of updates, and each queued message goes in when the run before it ends. AI Context Meter sits in the footer and shows how full the window is.
For the thread itself, see Use with shadcn chat.

