# File to context

Hand the model a file: drag it from the tree as a tilting chip and drop it into the composer.

Also called: drag file to chat.

> 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: Hand the model a file. Drag a file out of the tree and it hangs from your pointer as a chip, tilting as you move; drop it on the composer and it lands in a slot that opens for it. Click throws it along an arc. Preview: https://chatcn.dev/preview/file-to-context-demo

Drag a file out of the tree and it lifts into a chip that hangs from your pointer, tilting with the speed you move it. The composer lights up as you cross it, and letting go there drops the chip into the context row, which opens a slot for it. Let go anywhere else and it slides home. A click or Enter throws the chip along an arc into the same slot, so keyboard and mouse get the same story.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/file-to-context
```

## Usage

```tsx
import { FileToContext } from "@/components/ui/chatcn/pro/file-to-context"

<FileToContext files={paths} value={context} onValueChange={setContext} />
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `files` | `string[]` | Paths in the tree |
| `value` / `onValueChange` | `string[]` | Paths in context, in order |
| `placeholder` / `label` | `string` | Composer text and tree header |

## Keyboard

| Key | Action |
| --- | --- |
| `Enter` / `Space` on a file | Add it to context |

## Accessibility

- Files are buttons named Add, or in context; chips have a named remove button.

## Motion

- The chip follows the pointer with a tilt from its speed; drops land in 300 ms, throws arc in 520 ms. Reduced motion: chips just appear.

Source: https://chatcn.dev/docs/components/file-to-context