Mini chat (Pro)
ProIncluded in $99A picture in picture chat over the app: fling it to a corner, move it from the keyboard, or shrink it to a pill that follows the answer.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { MiniChat } from "@/components/ui/chatcn/pro/mini-chat"
<MiniChat
title="Harbourline assistant"
messages={messages}
status={status}
onSend={send}
onClose={() => setShown(false)}
/>It floats over the app so the reader can keep working while they ask. Drag it by its bar and let go: it travels to the nearest corner on the kit's spring, and a quick flick throws it to the corner it was heading for, measured from the pointer's velocity. From the keyboard, focus the bar and use the arrow keys. Shrink it and it becomes a pill that shows the last line of the answer as it arrives (or Answering before the first words), so the reader can follow along without the window in the way; click the pill to open it again. Corners follow the reading direction. placement="contained" keeps it inside its parent.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
messages | ChatcnMessage[] | The thread, in the kit's message contract |
status, error, onStop, onRetry | "ready" | "submitted" | "streaming" | "error" | Send becomes Stop while it streams; an error offers Try again |
value, defaultValue, onValueChange | string | The draft, controlled or not |
onSend | (text) => void | |
title | ReactNode | On the bar and in the window's name |
corner, defaultCorner, onCornerChange | "top-start" | "top-end" | "bottom-start" | "bottom-end" | Default bottom end |
collapsed, defaultCollapsed, onCollapsedChange | boolean | The pill |
onClose | () => void | Shows a close button |
placement | "fixed" | "contained" | Over the viewport, or inside the parent |
disabled | boolean | |
labels | Partial<MiniChatLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Arrow keys on the bar | Move to the corner in that direction |
| Escape | Shrink to the pill, focus on the pill |
| Enter or Space on the pill | Open the window, focus in the input |
| Enter, Shift Enter | Send, new line |
Accessibility
- The window is a non modal dialog, so the app behind it stays usable.
- The bar is a button that says it moves the window and how to do it from the keyboard.
- The pill is named by what it opens; its status dot always has the words beside it.
- Shrinking and opening move focus to the pill and back to the input.
Motion
Moving between corners uses the kit's critically damped spring, so a flick lands without overshoot. While dragging it follows the pointer exactly. Shrinking to the pill animates size and corner radius in 260 ms. Under reduced motion it jumps between corners and sizes.