Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

File drop zone

Drop, click or paste files into a real file input, so a plain form post sends them. Limits on type, size and count, a list with thumbnails, and French words out of the box.

Installation

pnpm add @heyramzi/ui

Usage

import { FileDropZone } from "@heyramzi/ui/components/file-drop-zone";

Keyboard and accessibility

Key Does
Tab Moves focus to the zone, then to each file's remove button.
Space Enter On the zone, opens the file picker.
  • The zone is a label over a visually hidden input type=file, so a screen reader announces a file field, and an outside label with for={id} names it.
  • Refusals (wrong format, too heavy, too many) sit in a polite live region tied to the input by aria-describedby.
  • Each remove button is named for its file, so a list of them reads apart.
  • With one file and no multiple, the file takes the zone's place, and removing it puts focus back on the zone.

API reference

name string
The file input's name: what the form post carries the files under.
id string
The id of the real input, for an outside `<label for>`.
accept string
Same syntax as the input's `accept`: `.pdf`, `application/pdf`, `image/*`.
multiple boolean
Default false
maxFiles number
Most files the list holds when `multiple` is set.
maxFileSize number
Largest file, in bytes.
required boolean
Default false
disabled boolean
Default false
capturePaste boolean
Default false
Takes files pasted anywhere on the page.
files bindable File[]
Default []
The chosen files. Kept in step with the real input, so a plain form post sends them.
onUpload (added: File[]) => void
Called with the files a drop, a paste or the picker just added.
onFileRejected (rejected: Rejection[]) => void
Called with each file turned away and why.
labels Partial<Labels>
class string
Prop Type Default
name

The file input's name: what the form post carries the files under.

string
id

The id of the real input, for an outside `<label for>`.

string
accept

Same syntax as the input's `accept`: `.pdf`, `application/pdf`, `image/*`.

string
multiple boolean false
maxFiles

Most files the list holds when `multiple` is set.

number
maxFileSize

Largest file, in bytes.

number
required boolean false
disabled boolean false
capturePaste

Takes files pasted anywhere on the page.

boolean false
files bindable

The chosen files. Kept in step with the real input, so a plain form post sends them.

File[] []
onUpload

Called with the files a drop, a paste or the picker just added.

(added: File[]) => void
onFileRejected

Called with each file turned away and why.

(rejected: Rejection[]) => void
labels Partial<Labels>
class string