Agent chat
What can you change for me?
Reading your opening hours
npx shadcn add https://ui.klarhimmel.com/r/agent-chat.json https://ui.klarhimmel.com/r/chat-composer.jsonCopy for AIExamples
Full
Chat start basic
DetailsAbout, usage, props and more
The chat every Klarhimmel app uses: an empty start with suggestions, the person's message as a bubble on the right, the reply as plain rich text with quiet actions, a small loader, the newest message scrolled to the top, and ChatComposer.
Preview
Where do we start?
Answers can be wrong.
Import
Import
- Files
- agent-chat.tsx, agent-chat.css, chat-composer.tsx, in components/klarhimmel/ui/. With it: menu, theme, utils. npm: lucide-react.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
ChatStart.greeting | ReactNode | required | |
ChatStart.children | ReactNode | required | The ChatComposer. |
ChatStart.suggestions | { label: string; icon?: ReactNode; onSelect: () => void }[] | [] | Up to four: each fills or sends a first message. |
ChatStart.className | string | - | Extra classes, merged after the component's own. |
ChatThread.children | ReactNode | required | |
ChatThread.composer | ReactNode | - | The ChatComposer, at the bottom of the view. |
ChatThread.anchor | string | number | - | Changes on each send: the id of the newest user message. |
ChatThread.scroll | 'page' | 'inner' | 'page' | page: scrolls with the page (default). inner: its own scroll area (give it a height), scrollbar hidden. |
ChatThread.jumpLabel | string | 'Scroll to the bottom' | |
ChatThread.className | string | - | Extra classes, merged after the component's own. |
ChatMessage.from | 'user' | 'assistant' | required | |
ChatMessage.children | ReactNode | required | |
ChatMessage.actions | ReactNode | - | user: a bubble on the right. assistant: plain rich text (headings, bold, lists, code), its MessageActions under it. |
ChatMessage.className | string | - | Extra classes, merged after the component's own. |
MessageActions.rating | 'good' | 'bad' | null | - | The person's rating, so the pressed thumb stays pressed. |
MessageActions.onRate | (rating: 'good' | 'bad' | null) => void | - | |
MessageActions.onRetry | () => void | - | |
MessageActions.copyText | string | - | The reply as text: Copy copies it and says Copied. |
MessageActions.more | { label: string; onSelect: () => void; danger?: boolean }[] | - | |
MessageActions.labels | Partial<MessageActionsLabels> | - | |
ChatLoader.label | string | 'Answering' | |
ChatLoader.className | string | - | Extra classes, merged after the component's own. |
ChatLoader.live | boolean | true | The Klarhimmel mark rising over its horizon where the reply will start; the label is for screen readers only. live: false inside a role=log, so it is not a second live region. |
ChatComposer.label | string | required | Required: names the text box (not shown). |
ChatComposer.value | string | required | |
ChatComposer.onChange | (value: string) => void | required | |
ChatComposer.onSend | (text: string) => void | required | Enter or the send button, with text that may be sent. The app clears `value`. |
ChatComposer.placeholder | string | - | |
ChatComposer.busy | boolean | - | An answer is streaming: send becomes stop (or a quiet Working without onStop). Typing goes on. |
ChatComposer.onStop | () => void | - |