File Dropzone
ComponentsFile Dropzone
FormsNew

File Dropzone

Select or drop files, validate type and size, and remove attachments before uploading.

USE IT FORProject attachmentsDocument submissionsImage selection
React + CSS
Explore the full-width experienceOpen preview

Project files

0

Drop files here

or choose from your device

PDF, PNG, JPG, or ZIP10 MB per file · 5 files maximum

No files selected5 slots available

Files stay in this preview.

Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/file-dropzone.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
'use client';

import { FileDropzone } from '@/components/anticraft/FileDropzone';

export function Example() {
  return <FileDropzone
    label="Attachments"
    accept=".pdf,.png,.jpg,.jpeg"
    fileTypesLabel="PDF, PNG, or JPG"
    maxFiles={5}
    maxSize={10 * 1024 * 1024}
    onFilesChange={files => {
      // Store these File objects for your own submit or upload handler.
      console.log(files);
    }}
  />;
}
03

Props

PropTypeDefaultDescription
labelstring'Attachments'Visible heading and accessible name for the selected-file section.
acceptstring''Comma-separated filename extensions, MIME types, or MIME wildcards, such as .pdf,image/*. Used by both the native picker and drop validation; an empty value permits all types. File extensions match without case sensitivity. When a browser supplies no MIME type, only an explicit matching extension (or */*) can accept that file. Client validation does not replace checks on your server.
fileTypesLabelstringaccept or Any file typeReadable format hint, such as PDF, PNG, or JPG. Does not affect validation.
multiplebooleantrueAllows additional selections to append files. When false, the first valid file in a selection replaces the current file; rejected selections retain the current file. A drop containing several valid files keeps the first and reports the remainder.
maxFilesnumber5Maximum accepted count when multiple is true. Files are processed in input order, retaining accepted files and reporting rejected ones. Nonfinite or values below 1 fall back to 5; fractional values round down. Changing this limit does not discard existing files.
maxSizenumber10485760 (10 MB)Maximum bytes per file, inclusive. Zero permits only empty files; negative or nonfinite values fall back to 10 MB. Changing the limit affects subsequent selections.
onFilesChange(files: File[]) => voidundefinedReceives a new array of actual File objects after accepted additions or removals. No callback on initial mount or a wholly rejected selection. This is local selection state: connect it to your upload handler or FormData when submitting. The native input is reset after each selection and is not a form-submission source.
disabledbooleanfalseDisables the picker, drop acceptance, and remove buttons while retaining selected files.
classNamestring''Additional root classes. Theme --ac-file-paper, --ac-file-ink, --ac-file-muted, --ac-file-line, --ac-file-accent, and --ac-file-focus. Maximum width is 640px.
04

Motion & accessibility

Considered by default.

Native file selection and file drag-and-drop. Duplicate files with identical name, size, lastModified, and type are rejected. Mixed selections retain valid files and announce the rejected names and reasons in a polite live region. Remove buttons are keyboard accessible; removing a file permits selecting it again. Attachment lists scroll when long. No uploads, network requests, object URLs, or simulated progress are created. The demo accepts PDF, PNG, JPG, and ZIP files, up to five files at 10 MB each. Reduced motion removes surface and button transitions.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.