185 Pro components and page blocks

Get Pro
All guides

Building an AI chat interface with shadcn

The pieces every AI chat needs, what each must handle, and components to install for them.

Updated

The parts

Every AI chat interface is built from the same five parts. Each has its own details to get right.

  1. A prompt input that grows, attaches files and turns send into stop.
  2. Messages that stream in without the page jumping.
  3. Sources and citations, so answers can be checked.
  4. Agent steps, when the model calls tools or asks for approval.
  5. Model state: thinking, context usage, errors.

shadcn/ui's base components give you the raw pieces: Textarea, Button, ScrollArea. The chat-specific behaviour is up to you, or a registry that ships it.

Prompt input

  • Grows with the text up to a limit, then scrolls.
  • Enter sends, Shift+Enter adds a line, and IME composition never sends early.
  • Files by button, drag and drop, and paste.
  • Send turns into stop while a reply streams.
  • Text comes back if sending fails.

Streaming messages

Sources and steps

Model state

Wiring it up

These components are the interface only. They take text and state as props and call you back, so they work with any model or SDK. With the Vercel AI SDK:

Terminal
npx shadcn@latest add https://uibrik.com/r/prompt-input.json
composer.tsx
"use client";

import { useChat } from "@ai-sdk/react";
import { PromptInput } from "@/components/uibrik/prompt-input/prompt-input";

export function Composer() {
  const { sendMessage, status, stop } = useChat();
  return (
    <PromptInput
      status={status === "streaming" ? "streaming" : "idle"}
      onSubmit={({ text }) => sendMessage({ text })}
      onStop={stop}
    />
  );
}

Questions

Does shadcn/ui have AI chat components?
shadcn/ui's base components cover the layout pieces, such as text areas, buttons and scroll areas. Chat-specific parts like a prompt input with attachments, streaming messages and citations come from registries such as uibrik.
Do these components call an AI model?
No. They are the interface only. Connect them to any model or SDK: pass the streamed text and state in as props.
What should a chat prompt input handle?
Multi-line text that grows, Enter to send and Shift+Enter for a new line, file attachments by button, drag and drop and paste, a stop button while a reply streams, and a disabled state.

More guides