Assistant chat app
AI chat app with an icon rail.
Usage
import { ChatApp } from '@/components/blocks/chat-01'
<ChatApp />
// Fill a parent that has a height instead of the viewport
<ChatApp height="100%" />
// Your own assistant, models and replies
<ChatApp
brand={{ name: 'Harbor', logo: <HarborMark /> }}
models={[
{ id: 'fast', name: 'Harbor Fast', description: 'Quick answers for everyday work' },
{ id: 'deep', name: 'Harbor Deep', description: 'Slower, more careful reasoning' },
]}
user={{ name: 'Sam Lee', plan: 'Team plan' }}
history={[
{ id: 'launch', title: 'Launch checklist', pinned: true },
{ id: 'retro', title: 'Sprint retro notes' },
]}
navItems={[
{ id: 'home', label: 'Home', icon: <HomeIcon /> },
{ id: 'library', label: 'Saved', icon: <BookmarkIcon /> },
{ id: 'projects', label: 'Projects', icon: <FolderIcon /> },
]}
defaultRoute="home"
onSend={(message, { chatId, model }) => track('send', { chatId, model: model.id })}
generateReply={async function* (message, { model, messages, signal }) {
const response = await fetch('/api/chat', {
method: 'POST',
body: JSON.stringify({ model: model.id, messages }),
signal,
})
const reader = response.body!.pipeThrough(new TextDecoderStream()).getReader()
while (true) {
const { value, done } = await reader.read()
if (done) break
yield value
}
}}
/>
Install
pnpm dlx shadcn@latest add @pastaui-pro/chat-01npx shadcn@latest add @pastaui-pro/chat-01yarn dlx shadcn@latest add @pastaui-pro/chat-01bunx --bun shadcn@latest add @pastaui-pro/chat-01Source
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| brand | ChatBrand | = PastaUI and its mark | Assistant name and logo. The logo tops the icon rail, and the name heads the Home panel and the disclaimer. |
| models | ChatModel[] | = Six current models from Anthropic, OpenAI, Google, DeepSeek and Mistral | Models in the composer’s model picker. Each: id, name, a one-line description, and an optional provider logo. The active one gets a blue check. |
| defaultModelId | string | = First model | Model selected on first render. |
| history | ChatHistoryItem[] | = Twelve sample chats, two pinned | Sidebar chats. Each: id, title and optional pinned. Pinned chats sit under Pinned and the rest under Recents. Rename, pin and delete update this list inside the block, and new chats are added at the top of Recents. |
| thread | ChatMessage[] | = A short thread about a debounce hook | Messages shown when a history chat is opened. Each: id, role ('user' or 'assistant') and content. Assistant content is Markdown: headings, lists, bold, inline code and fenced code blocks. |
| user | ChatUser | = { name: 'Mira Okafor', plan: 'Studio plan' } | Shown as the avatar at the foot of the icon rail, the drawer’s user row and the account menu. Pass avatar for an image, otherwise initials are used. |
| projects | ChatProject[] | = [] | Projects under Projects on Home and on the Projects route. Each: id, name and optional description, files, chats and updated. An empty list shows an empty state, and New project adds one inside the block. |
| navItems | ChatNavItem[] | = Home, Library, Reminders, Connectors, Projects | Icon rail routes in order. Each: id ('home', 'library', 'reminders', 'connectors' or 'projects'), label for the tooltip and panel title, and an icon shown at 20px. Relabel, reorder, swap icons or leave routes out. |
| defaultRoute | ChatRouteId | = 'home' | Route open on first render. |
| library | ChatLibraryItem[] | = Eight sample images, files and snippets | Saved items on the Library route. Each: id, title, kind ('image', 'file' or 'code'), meta, and optional src and collection. Collections are listed in the panel. |
| reminders | ChatReminder[] | = Five sample tasks | Scheduled tasks on the Reminders route. Each: id, title, schedule, nextRun and optional enabled. Switches update them inside the block. |
| connectors | ChatConnector[] | = Twelve sample apps | Apps on the Connectors route. Each: id, name, description, optional connected, health ('ok', 'warning' or 'error'), a short note for the status, and an optional full-colour logo. |
| modes | ChatMode[] | = Ask and Build | Segments of the toggle at the top of the empty state. Each: id, label, greeting and placeholder. The active mode is passed to onSend. |
| tools | ChatTool[] | = Search the web, Think it through, Make a picture | Tools in the composer’s + menu, under Attach files. Each: id, label, description and an optional icon. The picked tool shows as a removable blue chip and is passed to onSend and generateReply. |
| disclaimer | string | = A short accuracy note | The note under the composer in a conversation. |
| defaultChatId | string | null | = null | Open this history chat on first render instead of the empty state. |
| defaultSidebarOpen | boolean | = true | Whether the list panel beside the icon rail starts open. The rail always stays. |
| onSend | (message: string, context: ChatSendContext) => void | = — | Called when a message is sent, with the chat id, model, mode and tool. |
| generateReply | (message: string, context: ChatReplyContext) => string | Promise<string> | AsyncIterable<string> | = Canned sample replies | Produces the reply. Text is revealed word by word as it arrives. The context holds the model, earlier messages, the tool and an AbortSignal that fires when Stop is pressed or the chat changes. |
| height | number | string | = '100dvh' | Height of the shell; the panes scroll inside it. Numbers are pixels and strings take any CSS length: '100%' fills a parent that has a height, such as the area under your own header, and 800 gives a fixed frame. |
| className / style | string / CSSProperties | = — | Classes for the root (use height rather than an h-* class) and inline overrides for the --pp-* theme variables. |