Build an AI chat UI in React
The parts an AI chat or agent interface needs, from the prompt box to tool approvals, citations and handoff, and the free React components for each.
A chat box and a list of bubbles get an assistant talking. An agent needs more: a way to see what it's doing, to say yes before it acts, to check where an answer came from, and to reach a person when it's stuck. This page walks through those parts in the order a user meets them, with the Kokonut UI component for each. They're free, open source, and install with the shadcn CLI or your agent.
1. The prompt box
Where the user types, picks a model and attaches files. It should send on Enter, turn into Stop while a reply runs, and keep what was typed if the request fails.
- AI Input Selector: model menu, effort control, file chips and a
/command menu. - AI Input Search: a Tools menu (browse, investigate, run code) and a live trace of the sources being read.
- AI Voice: record, play back, then send.
- AI Model Selector: the model and how hard it thinks, on its own.
2. While it works
The gap between Send and the first word is where users decide the app is broken. Show that something is happening, and what.
- AI Text Loading: thinking words before the first token.
- AI State Loading: a list of steps with a live log and elapsed time.
- AI Tool Calls: each tool call as a row with a timer, folded into one line when the answer lands.
- AI Message Queue: let users keep typing; follow-ups wait above the composer.
3. Before it acts
Anything that sends, pays, deletes or changes files should ask first, and the ask should say exactly what will happen.
- AI Tool Approval: allow or deny each call; destructive ones need a press and hold.
- AI Diff Review: a coding agent's edits, accepted or rejected file by file.
- AI Send: a drafted email with a countdown you can undo.
- AI Redact: names, cards and keys masked before the prompt leaves.
4. The answer
An answer people can trust shows its sources and lets them steer.
- AI Inline Citations: a source chip beside each claim, with a preview of the passage.
- AI Conversation Branches: edit a message and keep both versions.
- AI Token Alternatives: see the words the model almost chose.
5. Answers that do something
When the reply is an action, a card beats a paragraph.
6. Around the conversation
- AI Context Meter: how full the context window is, and a way to compact it.
- AI Memory: what the assistant has learned about the user, editable.
- AI Connect: connect an app right where a tool needs it.
- AI Handoff: pass the chat to a person without making the user repeat themselves.
Put it together
Every component above plays a demo when you leave its data out, so you can lay out the whole interface first and wire it after.
- With the AI SDK, Use with the AI SDK shows which message part goes to which component.
- With shadcn/ui's Message and Bubble, Use with shadcn chat shows a full thread.
- With an agent, connect the Kokonut UI MCP server and ask for the parts by name.

