Skip to contents

Dropzone

A drop target primitive for drag-and-drop and click-to-select file selection.

View as Markdown

Drop files here

or click to open the file picker

No files selected yet.

Usage guidelines

  • Form controls must have an accessible name: Provide visible text in the dropzone, or set aria-label/aria-labelledby for icon-only UIs. See Labeling a dropzone and the forms guide.

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Labeling a dropzone

For icon-only designs, provide an explicit accessible name:

Icon-only dropzone

API reference

Root

Interactive drop target and file selection area. Renders a <div> element.

onDraggingChangefunction
Description

Event handler called when the dragging state changes.

Type
onFilesDropfunction
Description

Event handler called when files are dropped onto the dropzone.

Type
onOpenfunction
Name
Description

Event handler called when the dropzone is activated without a Dropzone.HiddenInput present. Use this to open a custom file picker when the built-in hidden input is not used.

Type
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
children| React.ReactNode
| ((state: { isDragging: boolean }) => React.ReactNode)
Description

The content of the dropzone. A render function can be used to access the dragging state.

Type
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-dragging

Present when files are being dragged over the dropzone.

data-disabled

Present when the dropzone is disabled.

AttributeDescription
data-dragging

Present when files are being dragged over the dropzone.

data-disabled

Present when the dropzone is disabled.

Dropzone.Root.PropsHide

Re-Export of Root props as DropzoneRootProps

Dropzone.Root.StateHide

HiddenInput

Hidden file input that enables file selection via the native file picker. Renders an <input> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

Dropzone.HiddenInput.PropsHide

Re-Export of HiddenInput props as DropzoneHiddenInputProps

Dropzone.HiddenInput.StateHide