Ballmac UI home

AI Chat

The layout for a chat UI: a message log that sticks to the bottom while replies stream unless the reader scrolls up, a jump-to-latest button, an empty state with suggestions and a footer.

YO
Where do Ballmac components get installed?
AI
Ballmac components install into components/ballmac, so they never overwrite your shadcn/ui files. Add one with `npx shadcn@latest add @ballmac/prompt-input`, then import it from @/components/ballmac/prompt-input.

Installation

$ pnpm dlx shadcn@latest add @ballmac/ai-chat

Usage

import { Chat, ChatMessages, ChatEmpty, ChatSuggestions, ChatSuggestion, ChatFooter, useChatScroll } from "@/components/ballmac/ai-chat"

The full example is in the Code tab above.

Examples

Empty state with suggestions

How can I help?

Ask about your code, docs or data.

API reference

<ChatMessages>

PropTypeDefault
contentClassName

Classes for the inner column that holds the messages (width, gap, padding).

string—
label

Accessible name of the log.

string—
scrollButtonLabel

Accessible name of the jump-to-latest button.

string—

<ChatEmpty>

PropTypeDefault
icon

Small mark above the title (an icon or logo).

React.ReactNode—
title

Headline, e.g. "How can I help?"

React.ReactNode—
description

One line under the title.

React.ReactNode—

<ChatSuggestions>

PropTypeDefault
onSelect

Called with a suggestion's value when it is clicked. Usually sends it as a message.

(value: string) => void—

<ChatSuggestion>

PropTypeDefault
value

Text passed to onSelect. Defaults to the button's text when children is a string.

string—

<ChatFooter>

PropTypeDefault
contentClassName

Classes for the inner column (match ChatMessages' width).

string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
TabFocuses the message log (scroll with arrow keys / Page Up / Page Down), then the jump-to-latest button when shown
Enter / SpaceOn a suggestion, sends it through onSelect
—The log is role=log with aria-live=polite; set aria-busy on ChatMessages while a reply streams to avoid announcing every token

Use with AI

Layout only: <Chat> (a full-height column) > <ChatMessages> (role=log, auto-scroll) + <ChatFooter>. Put ai-message items inside ChatMessages and a prompt-input inside ChatFooter. It holds no chat state, so any source works (Vercel AI SDK useChat, your own fetch stream). With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI AI Chat (@ballmac/ai-chat) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Building an assistant, support bot or copilot panel from ai-message and prompt-input
  • Any log that receives streaming content and should follow the newest line unless the reader scrolls up
  • A first-run screen with suggested prompts (ChatEmpty + ChatSuggestions)

Not for

  • A single one-off AI answer on a page (use ai-message or streaming-text alone)
  • Terminal-style command output (use terminal)

Registry JSON: https://ui.ballmac.com/r/ai-chat.json

Credits

Free to use in personal and commercial projects.