Skip to content
Browse docs and components

File Dropzone

file-dropzone

A drop target that is also a real file picker, so click, keyboard and drag all work. Checks type and size on drop as well as in the picker, and reports each rejected file by name.

Responsive

Install

$npxshadcnadd@forme/file-dropzone

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { FileDropzone } from "@/components/forme/file-dropzone/file-dropzone";

<FileDropzone
  accept="image/*"
  maxSize={10 * 1024 * 1024}
  hint="PNG or JPG up to 10 MB"
  onFiles={upload}
  onReject={(messages) => messages.forEach((message) => toast.error(message))}
/>

When to use

Reach for it

  • Uploading files by dropping them or picking them.
  • Any other drop target, like an avatar or a banner, built on the exported useFileDrop.

Use something else

  • A single small file in a dense form, where a plain file input fits better.

Examples

7 more ways to put it to work. Install one by name and it lands beside the component, or copy it from the Code tab into your app.

Avatar

A round profile photo that is itself the drop target, with an instant preview, a remove button and the size limit under it.

$npxshadcnadd@forme/file-dropzone-avatar
Responsive

Compact

One strip for a form: an Add files button, the picks as thumbnails beside it and a count against the limit.

$npxshadcnadd@forme/file-dropzone-compact
Responsive

Upload queue

Each file as a card with its own progress bar, a retry when one fails, and counts of what is done, running and failed.

$npxshadcnadd@forme/file-dropzone-progress
Responsive

Table

Documents in a table you drop straight onto, with a progress ring while each sends and download, retry and delete per row.

$npxshadcnadd@forme/file-dropzone-table
Responsive

Sortable

Listing photos you put in order by dragging a handle or with the arrow keys; the first one is the cover.

$npxshadcnadd@forme/file-dropzone-sortable
Responsive

Cover image

A wide banner with Change and Remove over the photo, a percent ring while the new one uploads, and the image guidelines below.

$npxshadcnadd@forme/file-dropzone-cover
Responsive

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

FileDropzone

A drop target that is also a button.

PropTypeDefaultDescription
labelReactNode"Drop files here or browse"
hintReactNode—Shown under the label, e.g. "PNG, JPG or PDF up to 10 MB".
classNamestring—
acceptstring—Passed to the file input, and checked again on drop, where the browser does not.
multipleboolean—
maxSizenumber—Bytes. Files over this are rejected with a message rather than silently dropped.
maxFilesnumber—How many files may be taken at once. Extra files are rejected by name.
disabledboolean—
onFiles(files: File[]) => void—Receives only the files that passed every check.
onReject(messages: string[]) => void—Receives a message for each rejected file.

Accessibility

  • The zone is a <label> for a hidden file input, so clicking, Enter, Space and the native picker all work.
  • Rejected files come back to onReject as messages to show, never silently dropped.

Responsive behaviour

  • On a phone, tapping opens the system file picker; dragging is only an extra path.