# Multimodal tray

Camera, screen, file, voice and a sketch pad in one tray that opens from the composer, with everything attached shown as previews above the text.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Multimodal tray. A café owner adds a counter photo, a voice note and a price list from one tray, then asks for the autumn board. Preview: https://chatcn.dev/preview/multimodal-tray-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/multimodal-tray
```

## Usage

```tsx
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

Example: Sketch pad. The tray open on its sketch pad. Draw, undo with Cmd Z, and attach the drawing as an image. Preview: https://chatcn.dev/preview/multimodal-tray-sketch

### States

Example: States. Nothing attached, one of each kind, uploading and failed, an input unavailable on a phone, streaming and disabled. Preview: https://chatcn.dev/preview/multimodal-tray-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-keyshortcuts` for its digit.
- Unavailable inputs stay focusable with `aria-disabled` and 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.

Source: https://chatcn.dev/docs/components/multimodal-tray