Skip to Content
Kokonut UI

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 partComponentWhat you pass
text, before the first tokenAI Text LoadingShow it while status is submitted; showElapsed adds the seconds
source-urlAI Inline CitationsThe text as parts, each part's cite ids, and the sources as sources
tool-*, read-only tools (search, fetch)AI Tool CallsOne row per part; its state is the part's state
tool-* with needsApprovalAI Tool ApprovalThe calls, and onRespond that calls addToolApprovalResponse
tool-* for sub-agentsAI Agent LanesA 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.

ToolComponentDraw it when
prepare_orderAI CheckoutThe order is ready to pay
track_orderAI Order StatusCall it again, or stream data parts, for fresh positions
find_timesAI ScheduleThe free slots from both calendars are back
draft_emailAI SendWhile its input streams, so the draft writes itself in
create_postAI PostPoll or stream to move rows from scheduled to posted
save_memoryAI MemoryThe model decides to keep or replace a fact
handoff_to_humanAI HandoffIts part reaches output-available with your ticket id
A tool that needs an appAI ConnectThe call stops for a missing connection, then retries

Streams

StreamComponentProp
streamText(...).textStream for a rewriteAI Inline Editrewrite returns the stream
A coding agent's file editsAI Diff Reviewfiles, and onDecision per file
Token log probabilitiesAI Token Alternativesslots 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.