Dropzone
A drop target primitive for drag-and-drop and click-to-select file selection.
View as MarkdownDrop 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-labelledbyfor icon-only UIs. See Labeling a dropzone and the forms guide.
Anatomy
Import the component and assemble its parts:
Examples
Labeling a dropzone
For icon-only designs, provide an explicit accessible name:
API reference
Root
Interactive drop target and file selection area.
Renders a <div> element.
nativeButtonbooleanfalse
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
- Default
false
onDraggingChangefunction—
- Name
- Description
Event handler called when the dragging state changes.
- Type
onFilesDropfunction—
- Name
- 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.HiddenInputpresent. Use this to open a custom file picker when the built-in hidden input is not used.- Type
disabledbooleanfalse
- Name
- Description
Whether the component should ignore user interaction.
- Type
- Default
false
children| React.ReactNode
| ((state: { isDragging: boolean }) => React.ReactNode)—
| ((state: { isDragging: boolean }) => React.ReactNode)
- Name
- Description
The content of the dropzone. A render function can be used to access the dragging state.
- Type
classNamestring | function—
- Name
- 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
ReactElementor 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.
| Attribute | Description | |
|---|---|---|
data-dragging | Present when files are being dragged over the dropzone. | |
data-disabled | Present when the dropzone is disabled. | |
Dropzone.Root.StateHide
HiddenInput
Hidden file input that enables file selection via the native file picker.
Renders an <input> element.
classNamestring | function—
- Name
- 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
ReactElementor a function that returns the element to render.- Type