Dropzone

A drag-and-drop file upload zone with accessible keyboard navigation and visual feedback.

Overview

The Dropzone component provides an accessible drag-and-drop area for file uploads. Built on React Aria, it includes keyboard navigation, screen reader support, and visual feedback for drag states. It supports multiple file selection, size and count limits, and integrates with the animated folder interaction for enhanced visual feedback. File type filtering is handled by the browser's native file picker via the accept prop — no runtime MIME type validation is performed.

Usage

Dropzone provides the drag-and-drop behavior and file picker. Use EmptyState sub-components for the visual content inside.

import {
  Dropzone,
  DropzoneAction,
  DropzoneFolderAnimation,
  EmptyStateMedia,
  EmptyStateHeading,
  EmptyStateTitle,
  EmptyStateDescription,
} from "@tilt-legal/cubitt-components/primitives";
<Dropzone onFileDrop={(files) => console.log(files)}>
  <EmptyStateMedia>
    <CloudUpload />
  </EmptyStateMedia>
  <EmptyStateHeading>
    <EmptyStateTitle>Drop files here</EmptyStateTitle>
    <EmptyStateDescription>or click to browse</EmptyStateDescription>
  </EmptyStateHeading>
</Dropzone>

Examples

With Action Button

Add a clickable button inside the dropzone to open the file picker dialog.

With Folder Animation

Use the animated folder component for enhanced visual feedback. The folder opens when files are dragged over the dropzone. When an accept prop is set on the parent Dropzone, file type icons are automatically shown on the document pages.

API Reference

Dropzone

Root component that handles drag-and-drop and file selection.

PropTypeDefaultDescription
onFileDrop(files: File[]) => void-Callback when valid files are dropped or selected
onFilesRejected(rejections: FileRejection[]) => void-Callback when files are rejected (size or count)
acceptstring | string[]-Passed to the native file input to filter the browser's file picker. No runtime validation is performed.
multiplebooleantrueAllow multiple file selection
maxSizenumber-Maximum file size in bytes
maxFilesnumber-Maximum number of files allowed
isDisabledbooleanfalseDisable the dropzone
variant"default" | "minimal" | "ghost""default"Visual variant style
getDropOperation(types) => DropOperation-Custom function to determine drop operation
onDrop(e: DropEvent) => void-Raw drop event callback (from React Aria)
childrenReactNode-Composable sub-components
classNamestring-Additional CSS classes

FileRejection Type

type FileRejection = {
  file: File;
  reason: "size" | "count";
  message: string;
};

DropzoneFolderAnimation

Animated folder component with documents that fan out when opened. Automatically responds to drag events when used inside a Dropzone.

PropTypeDefaultDescription
showFileTypeIconsbooleantrueShow file type icons on documents based on parent accept prop
classNamestring-Additional CSS classes

The folder automatically opens when files are dragged over the parent Dropzone.

DropzoneAction

Wrapper for action buttons. Handles click propagation to open the file picker.

PropTypeDefaultDescription
childrenReactNode-Button or interactive element
classNamestring-Additional CSS classes

On this page