File Dropzone
ProNewA drop target that is also a real file input. It lifts while a file is held over it and explains what it rejected.
Installation
pnpm dlx shadcn@latest add @viewport/file-dropzone
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| onFiles* | (files: File[]) => voidReceives the files that passed the `accept` and `maxSize` checks. | — |
| accept | stringAllowed types, as for a file input: `".pdf,.docx"`, `"image/*"`. | — |
| multiple | boolean | true |
| maxSize | numberThe largest file allowed, in bytes. | — |
| disabled | boolean | — |
| title | stringThe main line. | "Drop files here or browse" |
| hint | stringThe second line, e.g. the accepted types and size limit in words. | — |
| className | string | — |
Accessibility
- A labelled file input: works with a click, the keyboard and a screen reader.
- Rejections are announced with the file name and the reason.
- The shake is skipped under reduced motion; the message remains.