Multimodal tray (Pro)
ProIncluded in $99Camera, screen, file, voice and a sketch pad in one tray that opens from the composer, with everything attached shown as previews above the text.
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 { MultimodalTray } from "@/components/ui/chatcn/pro/multimodal-tray"
<MultimodalTray
items={items}
onItemsChange={setItems}
onPick={(kind) => capture(kind)}
onFiles={(files) => upload(files)}
onSubmit={({ text, items }) => send(text, items)}
/>The + in the toolbar opens one tray for every way in, and turns into a close mark while it is open. Arrow keys move across the five inputs and 1 to 5 pick directly. Camera, screen and voice call onPick so your app captures with the APIs it already uses; File also opens the composer's file picker when onFiles is set; Sketch opens a pad inside the tray, so a quick diagram never leaves the composer, and attaches it as an SVG image in the pad's own colors. Everything attached sits above the text in one scrolling row: photos, screens and sketches as thumbnails, files as cards with upload progress and errors, voice notes with their waveform and a play button. Inputs that cannot work here (screen capture on a phone) stay visible, dimmed, with the reason. Attached items count as content, so Send works without text.
Examples
Sketch pad
States
Props
| Prop | Type | Notes |
|---|---|---|
items, defaultItems, onItemsChange | TrayAttachment[] | { id, kind, name, previewUrl?, size?, type?, duration?, peaks?, status?, progress?, error? } |
kinds | TrayKind[] | Which inputs the tray offers, in order. Default all five |
unavailable | Partial<Record<TrayKind, string>> | Inputs that cannot be used here, with the reason |
onPick | (kind: "camera" | "screen" | "file" | "voice") => void | Capture is yours; add the result to items |
onSketch | ({ svg, url, width, height }) => void | A sketch was attached. Uncontrolled, it is added for you |
defaultSketch | [number, number][][] | Strokes already on the pad |
trayOpen, onTrayOpenChange | boolean | The tray, controlled |
onSubmit | ({ text, items }) => void | |
value, defaultValue, onValueChange | string | The draft, controlled or not |
status, onStop | "idle" | "submitting" | "streaming", () => void | Send becomes Stop in the same footprint |
disabled | boolean | |
tools, actions | ReactNode | After the +, and before Send |
labels | Partial<MultimodalTrayLabels> | Every string, for translation |
| ... | PromptInputProps | onFiles, accept, maxFiles and the rest pass through |
Keyboard
| Key | Action |
|---|---|
| Enter or Space on + | Open the tray, focus on the first input |
| Left, Right, Home, End | Move between inputs |
| 1 to 5 | Pick an input directly |
| Cmd Z or Ctrl Z | Undo the last stroke on the sketch pad |
| Escape | Close the tray, focus back in the message |
Accessibility
- The inputs are a toolbar with one tab stop and roving focus; each has
aria-keyshortcutsfor its digit. - Unavailable inputs stay focusable with
aria-disabledand the reason as their description. - The sketch pad is named with its stroke count; every pad action is a labelled button.
- Voice notes play from a toggle button with
aria-pressed; remove buttons name the item.
Motion
The tray opens from the + in 180 ms like every kit popover while the + turns 45 degrees into a close mark. New previews enter in 150 ms from 0.96 scale, removed ones leave in 140 ms. Reduced motion keeps the fades and drops the turn.