Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rijvi-mahmud/shaddy/llms.txt
Use this file to discover all available pages before exploring further.
Dropzone is a compound file-upload component built on top of react-dropzone and shadcn/ui’s Button primitive. It provides a flexible, accessible drag-and-drop area with built-in upload state tracking, per-file error messages, retry logic, and an animated progress indicator. The compound API separates concerns into small, composable sub-components — DropZoneArea, DropzoneTrigger, DropzoneFileList, and more — so you can assemble exactly the upload UI your application needs without being locked into a fixed layout.
Installation
Install manually — dependencies
If you prefer to install by hand, start with the required npm package:
Usage
The component is driven by theuseDropzone hook, which manages file state and upload logic. Pass the hook’s return value as props to the <Dropzone> context provider, then compose the sub-components inside it.
useDropzone hook
The useDropzone hook is the heart of the component. It wraps react-dropzone and adds upload lifecycle management.
Props
onDropFile
(file: File) => Promise<{ status: 'success'; result: TUploadRes } | { status: 'error'; error: TUploadError }>
Required. Called once for each accepted file. Return
{ status: 'success', result } on success or { status: 'error', error } on failure. The hook uses the returned value to update the file’s status in fileStatuses.MIME type map restricting which file types are accepted. Uses the same format as the
react-dropzone accept option — e.g. { 'image/*': ['.png', '.jpg'] }.Maximum file size in bytes. Files exceeding this limit are rejected and a human-readable error message is shown automatically.
Minimum file size in bytes.
Maximum total number of files allowed. Defaults to unlimited.
When
true and the user drops files that would exceed maxFiles, the oldest files are automatically removed to make room. When false (default), excess files are rejected and an error is displayed.Maximum number of times a failed upload can be retried via
DropzoneRetryFile. Defaults to unlimited.When
true, failed uploads are retried automatically (up to maxRetryCount times) without user interaction.Required when
TUploadError is not a string. Converts your error type to a display string shown by DropzoneFileMessage.Optional callback invoked when a file is removed from the list — useful for cleaning up server-side state.
Called each time an individual file finishes uploading successfully.
Called each time an individual file upload fails.
Called once after all files in a single drop batch have finished processing (success or error).
Called when the root validation error changes — e.g. when a user drops too many files or an invalid file type.
Sub-components
<Dropzone>
Context provider that makes the useDropzone return value available to all child sub-components. Spread the hook result directly onto it:
<DropZoneArea>
The drag-and-drop target region. Highlights with a pulse animation while a drag is active and applies a destructive border when there is a validation error. Accepts any div HTML attributes plus className.
<DropzoneTrigger>
A styled <label> element that wraps the hidden file <input>. Clicking it opens the native file browser. Place any text or icon as its children.
<DropzoneDescription>
A <p> element pre-styled as text-sm text-muted-foreground. Use it to communicate accepted types or size limits to the user.
<DropzoneMessage>
Displays the current root validation error (e.g. “Only image/png are allowed”, “Max 4 files”) as a destructive-coloured <p>. Renders nothing when there is no error.
<DropzoneFileList>
An accessible <ol> container for the list of file items. Apply spacing via className.
<DropzoneFileListItem>
Wraps a single FileStatus entry and provides per-file context to DropzoneFileMessage, DropzoneRemoveFile, and DropzoneRetryFile. Requires the file prop:
<DropzoneFileMessage>
Shows the upload error message for the enclosing file item when its status is "error". When the file status is not "error", renders its children instead — use this for a custom success or pending message.
<DropzoneRemoveFile>
A Button (icon size by default) that calls onRemoveFile for the enclosing file item when clicked. Forwards all ButtonProps.
<DropzoneRetryFile>
A Button that calls onRetry for the enclosing file item. Automatically disabled (via aria-disabled) when the file cannot be retried (e.g. maxRetryCount reached). Forwards all ButtonProps.
<InfiniteProgress>
An animated progress bar that displays an indeterminate pulse while a file is "pending", fills solid on "success", and turns destructive red on "error". Requires a status prop:
status must be one of "pending" | "success" | "error".
FileStatus type
fileStatuses from the hook is an array of FileStatus<TUploadRes, TUploadError> objects:
Dropzone is fully generic — useDropzone<TUploadRes, TUploadError>() lets you type the upload result and error shapes to match your API exactly.