File drop
Drag files over the well and its floor sinks away. Let go and they fly into the list, each row filling as it uploads. Remove one and you have five seconds to undo.
npx shadcn@latest add @uimaxxer/file-dropPasskeysContext
Context
Context for this run
Drop files, or click to browsePDF, CSV, Markdown, code or images, up to 25 MB
q3-revenue-by-region.csv
184 KB
refund-policy-2026.md
14 KB
File drop is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { FileDrop } from "@/components/ui/file-drop"
<FileDrop
accept=".pdf,.csv,image/*"
maxSize={25 * 1024 * 1024}
onUpload={(file, progress, signal) => upload(file, { onProgress: progress, signal })}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| onUpload | (file: File, progress: (fraction: number) => void, signal: AbortSignal) => Promise<void> | Uploads one file. Report progress from 0 to 1; reject to mark it failed. The signal aborts on remove. | |
| onFilesChange | (files: DropFile[]) => void | Every file still in the list, with its status and progress. | |
| accept | string | As the input attribute, e.g. ".pdf,.csv,image/*". Other files are listed with an error. | |
| maxSize | number | Bytes. Larger files are listed with an error and never uploaded. | |
| multiple | boolean | true | Accept more than one file. |
| defaultFiles | { name: string; size: number; type?: string }[] | Files already uploaded. | |
| label / hint | ReactNode | The well's line, and what it accepts. | |
| undoFor | number | 5000 | How long a removed file can come back, in ms. |
Keyboard
- Enter / Space
- Open the file browser
- Tab
- To each file's remove and undo buttons
Accessibility
- The well is a button that opens the native file picker, so keyboard and screen readers never need drag and drop.
- Each uploading row carries a progressbar with its percentage.
- Adds, removals and undos are announced through a polite live region.