Skip to content

FileDropZone

Drag files in or use the Choose files button; chosen files are listed with remove buttons and every change is announced.

  • Pro
  • Version 2.0.0-rc.1
  • APG pattern: Drop zone with a file button

Examples

Still previews of the real component, rendered from its stories. Pro code isn’t public, so nothing in them responds. Switch the theme and density for every preview at once.

Default

Upload receipts

Drag files here, or

PDF, PNG or JPG, up to 10 MB each.

Show the code

Default, code

<FileDropZone
  label="Upload receipts"
  hint="PDF, PNG or JPG, up to 10 MB each."
  acceptedFileTypes={['application/pdf', 'image/png', 'image/jpeg']}
/>

One file

Upload a logo

Drag files here, or

SVG or PNG.

Show the code

One file, code

<FileDropZone
  acceptedFileTypes={['application/pdf', 'image/png', 'image/jpeg']}
  label="Upload a logo"
  allowsMultiple={false}
  hint="SVG or PNG."
/>

Tokens

The 14 design tokens FileDropZone reads, with the value each has in the theme and density chosen above. Change a token and the component follows, in Figma and in code.

Show all 14 tokens
Tokens FileDropZone reads
TokenValue nowCSS variable
color.bg.brand-subtle…--sd-color-bg-brand-subtle
color.bg.subtle…--sd-color-bg-subtle
color.border.brand…--sd-color-border-brand
color.border.control…--sd-color-border-control
color.border.default…--sd-color-border-default
color.border.subtle…--sd-color-border-subtle
color.icon.default…--sd-color-icon-default
color.text.default…--sd-color-text-default
color.text.secondary…--sd-color-text-secondary
shape.radius-surface…--sd-shape-radius-surface
spacing.gap.sm…--sd-spacing-gap-sm
spacing.inset.md…--sd-spacing-inset-md
spacing.inset.xl…--sd-spacing-inset-xl
spacing.stack.sm…--sd-spacing-stack-sm

Install

Pro components come as source from the SuperDuper registry, with a licence key from Solo, Team or Studio. The registry and checkout aren’t open yet.

Add it from the registry (Pro licence key)

npx shadcn@latest add @superduperui/file-drop-zone

Then import it

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

Props

FileDropZone props
PropTypeWhat it does
labelstringDefault 'Upload files'Heading inside the zone. Default "Upload files".
hintstringWhat is accepted, shown as text (e.g. "PDF or PNG, up to 10 MB each").
acceptedFileTypesstring[]MIME types or extensions for the picker and drops, e.g. ["image/png", "application/pdf"].
allowsMultiplebooleanDefault true
onChange(files: File[]) => voidCalled with the full list after each change.
classNamestring

When to use it

Use it for

  • Uploading documents, receipts, images
  • Any multi-file upload

Use something else for

  • A single avatar or logo next to a preview: a Button with FileTrigger is enough

Accessibility

Screen readers announce "Upload receipts, drop zone" then "Choose files, button"; after a choice "2 files added".

WCAG 2.2 AAA criteria the component meets in Comfortable density: 1.4.6, 1.4.9, 2.1.3, 2.3.2, 2.4.13, 2.5.5, 2.5.6.

Compact density meets AA (2.5.8, 24px targets), not AAA.

What your product still has to do

  • State accepted types and size limits in the hint
  • Report upload failures per file

Shared patterns it ships with: 3.3.6 (files can be removed before submitting).

This release’s test results

Test results for FileDropZone in this release
axe-core (WCAG A, AA, AAA and best practice)60 runs across every story, theme, density and width: 0 violations
Rendered text contrast165 text runs: 0 below 7:1, lowest 10.58:1
Target size28 targets: 0 under 44px in Comfortable
Focus appearance (2.4.13)36 focus stops in 3 browser engines: all pass
Keyboard scriptChromium 2 of 2, Firefox 2 of 2, WebKit 2 of 2

Manual passes with VoiceOver and NVDA haven’t been done yet.

Keyboard

Each step is scripted and run in Chromium, Firefox and WebKit.

FileDropZone keyboard steps
KeyWhat happens
TabTab reaches the drop zone (a keyboard drop target for pasted files)
TabTab reaches Choose files: the keyboard and switch path to add files

In Figma

The Figma component is FileDropZone, with State (Default, Drop target, Focus). The Figma library isn’t published yet.

Figma to code: State (Default, Drop target, Focus; preview only); Label → label; Hint → hint when Show hint; nested Choose files → (FileTrigger).