Skip to content
Aback UI

Dropzone

A keyboard-operable drag-and-drop file area that validates type, size, and count.

BetaUsed in Aback ToolsRegistry JSON (opens in a new tab)

Installation

Copy the source with the CLI to own and edit it, or import it from the npm package.

npx aback-ui@latest add dropzone

Writes components/ui/dropzone.tsx. First time in this project? Run npx aback-ui@latest init first, as the installation guide shows.

Usage

Import the parts you need from the installed file. The Code tab above has a complete, working example.

tsx
import { Dropzone, fileMatchesAccept, formatFileSize } from "@/components/ui/dropzone";

API reference

Props and composition points for Dropzone. Native element props pass through.

PropTypeDefaultDescription
onFilesAccepted(files: File[]) => voidNoneCalled with files that passed the type, size, and count checks. Required.
onFilesRejected(rejections: { file, reason }[]) => voidNoneCalled with each refused file and a reason of "type", "size", or "count", so the page can explain it.
acceptstringNoneNative accept syntax: ".pdf", "image/png", "image/*". It filters the picker and is also enforced for dropped files.
multiple / maxFilesboolean / numberfalse / 1 or unlimitedAllow several files, and cap how many one selection may add.
maxSizenumberNoneLargest accepted file in bytes.
label / description / hintReactNode"Drop a file here" / "or click to browse"The label is the input's accessible name; the description and hint are its description.
icon / disabled / inputPropsReactNode / boolean / input propsNoneReplace the upload glyph, disable the area, or pass name, id, or extra aria attributes to the file input.
fileMatchesAccept / formatFileSizehelpersNoneThe exported accept check and a 1024-based size formatter for file rows.

Dependencies: @tabler/icons-react, plus the shared @/lib/utils helper.

Accessibility

Semantics, keyboard behavior, and the decisions that keep the component operable.

  • A real file input sits under the area, visually hidden but focusable. Tab reaches it, Enter or Space opens the picker, and the frame shows the focus ring.
  • The visible label names the input and the hint describes it, so the accepted formats are announced before choosing.
  • Dropping is a convenience, not the only path: the picker always works.
  • Announce results yourself. The example writes accepted and rejected outcomes to a role=status line instead of relying on colour.

Keyboard

KeyAction
TabFocus the file input.
EnterorSpaceOpen the system file picker.

Used in production

The Aback products whose interfaces shaped this component.