Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

File Dropzone

ProNew

A 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

PropTypeDefault
onFiles*(files: File[]) => void

Receives the files that passed the `accept` and `maxSize` checks.

—
acceptstring

Allowed types, as for a file input: `".pdf,.docx"`, `"image/*"`.

—
multiplebooleantrue
maxSizenumber

The largest file allowed, in bytes.

—
disabledboolean—
titlestring

The main line.

"Drop files here or browse"
hintstring

The second line, e.g. the accepted types and size limit in words.

—
classNamestring—

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.