Dropzone

Dropzone

A Shadcn/UI style component for file uploads.

Installation

This is assuming you have Shadcnn/UI set up in your project. If you haven't, follow this guide.

npm i react-dropzone;
npx shadcn add@latest add button;

Usage

import {
  Dropzone,
  DropZoneArea,
  DropzoneDescription,
  DropzoneFileList,
  DropzoneFileListItem,
  DropzoneFileMessage,
  DropzoneTrigger,
  DropzoneMessage,
  DropzoneRemoveFile,
  DropzoneRetryFile,
  InfiniteProgress,
  useDropzone,
} from "@/components/dropzone";
const dropzone = useDropzone();
 
return (
  <Dropzone {...dropzone}>
    <DropzoneDescription>
      These will be uploaded to the server.
    </DropzoneDescription>
    <DropzoneMessage />
    <DropZoneArea>
      <DropzoneTrigger>
        Click here or drag and drop files to upload them
      </DropzoneTrigger>
      <DropzoneFileList>
        {dropzone.fileStatuses.map((file) => (
          <DropzoneFileListItem key={file.id} file={file}>
            <DropzoneRetryFile>Retry</DropzoneRetryFile>
            <DropzoneRemoveFile>Remove</DropzoneRemoveFile>
            <DropzoneFileMessage />
            <InfiniteProgress status={file.status} />
          </DropzoneFileListItem>
        ))}
      </DropzoneFileList>
    </DropZoneArea>
  </Dropzone>
);

Examples

(None of the below examples actually upload files to a server, don't worry!)

Single File

With image previews

Please select up to 10 images

    Multiple files

    Please select up to 10 files

      On this page