useDropZone
Handles file drag-and-drop interactions with MIME/extension filtering via a target ref or getRootProps.
Loading preview...
The useDropZone hook manages drag-and-drop file uploads, tracks nested drag-enter depth so isOver does not flicker over child elements, and filters dropped files by MIME type or file extension.
Installation
Usage
Examples
Drop Zone with getRootProps
Spread getRootProps() onto your container element when you do not already have a separate RefObject.
Attaching to an Existing RefObject
Pass target in the options object to attach drag listeners directly to an existing element ref.
API Reference
UseDropZoneOptions
Configuration options and event callbacks for the drop zone.
Property
Specification
accept?union
Accepted MIME types or file extensions (e.g.,
'image/*,.pdf' or ['image/png', '.jpg'])Full Signature
multiple?uniondefault:true
Allow dropping multiple files at once
Full Signature
disabled?uniondefault:false
Disable drag-and-drop handling
Full Signature
preventDefaultForUnhandled?uniondefault:false
Prevent default browser behavior for drops outside the drop zone
Full Signature
onDrop?function
Callback invoked when valid files are dropped
Full Signature
Parameters
(filesFile[], event: DragEvent | ReactDragEventonDropRejected?function
Callback invoked when dropped files fail MIME/extension or
multiple validationFull Signature
Parameters
(rejectedFilesFile[], event: DragEvent | ReactDragEventonDragEnter?function
Callback invoked when a dragged item enters the drop zone
Full Signature
Parameters
(eventDragEvent | ReactDragEventonDragOver?function
Callback invoked while a dragged item moves over the drop zone
Full Signature
Parameters
(eventDragEvent | ReactDragEventonDragLeave?function
Callback invoked when a dragged item leaves the drop zone
Full Signature
Parameters
(eventDragEvent | ReactDragEventDropZoneRootProps
Drag event handlers returned by getRootProps().
Property
Specification
onDragEnterrequiredfunction
Drag enter handler to attach to the drop zone element
Full Signature
Parameters
eventReactDragEvent<HTMLElement>onDragOverrequiredfunction
Drag over handler to attach to the drop zone element
Full Signature
Parameters
eventReactDragEvent<HTMLElement>onDragLeaverequiredfunction
Drag leave handler to attach to the drop zone element
Full Signature
Parameters
eventReactDragEvent<HTMLElement>onDroprequiredfunction
Drop handler to attach to the drop zone element
Full Signature
Parameters
eventReactDragEvent<HTMLElement>children?ReactNode
Full Signature
dangerouslySetInnerHTML?object
Full Signature
onCopy?ClipboardEventHandler<object>
Full Signature
onCopyCapture?ClipboardEventHandler<object>
Full Signature
onCut?ClipboardEventHandler<object>
Full Signature
onCutCapture?ClipboardEventHandler<object>
Full Signature
onPaste?ClipboardEventHandler<object>
Full Signature
onPasteCapture?ClipboardEventHandler<object>
Full Signature
onCompositionEnd?CompositionEventHandler<object>
Full Signature
onCompositionEndCapture?CompositionEventHandler<object>
Full Signature
onCompositionStart?CompositionEventHandler<object>
Full Signature
onCompositionStartCapture?CompositionEventHandler<object>
Full Signature
onCompositionUpdate?CompositionEventHandler<object>
Full Signature
onCompositionUpdateCapture?CompositionEventHandler<object>
Full Signature
onFocus?FocusEventHandler<object>
Full Signature
onFocusCapture?FocusEventHandler<object>
Full Signature
onBlur?FocusEventHandler<object>
Full Signature
onBlurCapture?FocusEventHandler<object>
Full Signature
onChange?ChangeEventHandler<object, object>
Full Signature
onChangeCapture?ChangeEventHandler<object, object>
Full Signature
onBeforeInput?InputEventHandler<object>
Full Signature
onBeforeInputCapture?InputEventHandler<object>
Full Signature
onInput?InputEventHandler<object>
Full Signature
onInputCapture?InputEventHandler<object>
Full Signature
onReset?ReactEventHandler<object>
Full Signature
onResetCapture?ReactEventHandler<object>
Full Signature
onSubmit?SubmitEventHandler<object>
Full Signature
onSubmitCapture?SubmitEventHandler<object>
Full Signature
onInvalid?ReactEventHandler<object>
Full Signature
onInvalidCapture?ReactEventHandler<object>
Full Signature
onLoad?ReactEventHandler<object>
Full Signature
onLoadCapture?ReactEventHandler<object>
Full Signature
onError?ReactEventHandler<object>
Full Signature
onErrorCapture?ReactEventHandler<object>
Full Signature
onKeyDown?KeyboardEventHandler<object>
Full Signature
onKeyDownCapture?KeyboardEventHandler<object>
Full Signature
onKeyPress?deprecatedKeyboardEventHandler<object>
Full Signature
onKeyPressCapture?deprecatedKeyboardEventHandler<object>
Full Signature
onKeyUp?KeyboardEventHandler<object>
Full Signature
onKeyUpCapture?KeyboardEventHandler<object>
Full Signature
onAbort?ReactEventHandler<object>
Full Signature
onAbortCapture?ReactEventHandler<object>
Full Signature
onCanPlay?ReactEventHandler<object>
Full Signature
onCanPlayCapture?ReactEventHandler<object>
Full Signature
onCanPlayThrough?ReactEventHandler<object>
Full Signature
onCanPlayThroughCapture?ReactEventHandler<object>
Full Signature
onDurationChange?ReactEventHandler<object>
Full Signature
onDurationChangeCapture?ReactEventHandler<object>
Full Signature
onEmptied?ReactEventHandler<object>
Full Signature
onEmptiedCapture?ReactEventHandler<object>
Full Signature
onEncrypted?ReactEventHandler<object>
Full Signature
onEncryptedCapture?ReactEventHandler<object>
Full Signature
onEnded?ReactEventHandler<object>
Full Signature
onEndedCapture?ReactEventHandler<object>
Full Signature
onLoadedData?ReactEventHandler<object>
Full Signature
onLoadedDataCapture?ReactEventHandler<object>
Full Signature
onLoadedMetadata?ReactEventHandler<object>
Full Signature
onLoadedMetadataCapture?ReactEventHandler<object>
Full Signature
onLoadStart?ReactEventHandler<object>
Full Signature
onLoadStartCapture?ReactEventHandler<object>
Full Signature
onPause?ReactEventHandler<object>
Full Signature
onPauseCapture?ReactEventHandler<object>
Full Signature
onPlay?ReactEventHandler<object>
Full Signature
onPlayCapture?ReactEventHandler<object>
Full Signature
onPlaying?ReactEventHandler<object>
Full Signature
onPlayingCapture?ReactEventHandler<object>
Full Signature
onProgress?ReactEventHandler<object>
Full Signature
onProgressCapture?ReactEventHandler<object>
Full Signature
onRateChange?ReactEventHandler<object>
Full Signature
onRateChangeCapture?ReactEventHandler<object>
Full Signature
onSeeked?ReactEventHandler<object>
Full Signature
onSeekedCapture?ReactEventHandler<object>
Full Signature
onSeeking?ReactEventHandler<object>
Full Signature
onSeekingCapture?ReactEventHandler<object>
Full Signature
onStalled?ReactEventHandler<object>
Full Signature
onStalledCapture?ReactEventHandler<object>
Full Signature
onSuspend?ReactEventHandler<object>
Full Signature
onSuspendCapture?ReactEventHandler<object>
Full Signature
onTimeUpdate?ReactEventHandler<object>
Full Signature
onTimeUpdateCapture?ReactEventHandler<object>
Full Signature
onVolumeChange?ReactEventHandler<object>
Full Signature
onVolumeChangeCapture?ReactEventHandler<object>
Full Signature
onWaiting?ReactEventHandler<object>
Full Signature
onWaitingCapture?ReactEventHandler<object>
Full Signature
onAuxClick?MouseEventHandler<object>
Full Signature
onAuxClickCapture?MouseEventHandler<object>
Full Signature
onClick?MouseEventHandler<object>
Full Signature
onClickCapture?MouseEventHandler<object>
Full Signature
onContextMenu?MouseEventHandler<object>
Full Signature
onContextMenuCapture?MouseEventHandler<object>
Full Signature
onDoubleClick?MouseEventHandler<object>
Full Signature
onDoubleClickCapture?MouseEventHandler<object>
Full Signature
onDrag?DragEventHandler<object>
Full Signature
onDragCapture?DragEventHandler<object>
Full Signature
onDragEnd?DragEventHandler<object>
Full Signature
onDragEndCapture?DragEventHandler<object>
Full Signature
onDragEnterCapture?DragEventHandler<object>
Full Signature
onDragExit?DragEventHandler<object>
Full Signature
onDragExitCapture?DragEventHandler<object>
Full Signature
onDragLeaveCapture?DragEventHandler<object>
Full Signature
onDragOverCapture?DragEventHandler<object>
Full Signature
onDragStart?DragEventHandler<object>
Full Signature
onDragStartCapture?DragEventHandler<object>
Full Signature
onDropCapture?DragEventHandler<object>
Full Signature
onMouseDown?MouseEventHandler<object>
Full Signature
onMouseDownCapture?MouseEventHandler<object>
Full Signature
onMouseEnter?MouseEventHandler<object>
Full Signature
onMouseLeave?MouseEventHandler<object>
Full Signature
onMouseMove?MouseEventHandler<object>
Full Signature
onMouseMoveCapture?MouseEventHandler<object>
Full Signature
onMouseOut?MouseEventHandler<object>
Full Signature
onMouseOutCapture?MouseEventHandler<object>
Full Signature
onMouseOver?MouseEventHandler<object>
Full Signature
onMouseOverCapture?MouseEventHandler<object>
Full Signature
onMouseUp?MouseEventHandler<object>
Full Signature
onMouseUpCapture?MouseEventHandler<object>
Full Signature
onSelect?ReactEventHandler<object>
Full Signature
onSelectCapture?ReactEventHandler<object>
Full Signature
onTouchCancel?TouchEventHandler<object>
Full Signature
onTouchCancelCapture?TouchEventHandler<object>
Full Signature
onTouchEnd?TouchEventHandler<object>
Full Signature
onTouchEndCapture?TouchEventHandler<object>
Full Signature
onTouchMove?TouchEventHandler<object>
Full Signature
onTouchMoveCapture?TouchEventHandler<object>
Full Signature
onTouchStart?TouchEventHandler<object>
Full Signature
onTouchStartCapture?TouchEventHandler<object>
Full Signature
onPointerDown?PointerEventHandler<object>
Full Signature
onPointerDownCapture?PointerEventHandler<object>
Full Signature
onPointerMove?PointerEventHandler<object>
Full Signature
onPointerMoveCapture?PointerEventHandler<object>
Full Signature
onPointerUp?PointerEventHandler<object>
Full Signature
onPointerUpCapture?PointerEventHandler<object>
Full Signature
onPointerCancel?PointerEventHandler<object>
Full Signature
onPointerCancelCapture?PointerEventHandler<object>
Full Signature
onPointerEnter?PointerEventHandler<object>
Full Signature
onPointerLeave?PointerEventHandler<object>
Full Signature
onPointerOver?PointerEventHandler<object>
Full Signature
onPointerOverCapture?PointerEventHandler<object>
Full Signature
onPointerOut?PointerEventHandler<object>
Full Signature
onPointerOutCapture?PointerEventHandler<object>
Full Signature
onGotPointerCapture?PointerEventHandler<object>
Full Signature
onGotPointerCaptureCapture?PointerEventHandler<object>
Full Signature
onLostPointerCapture?PointerEventHandler<object>
Full Signature
onLostPointerCaptureCapture?PointerEventHandler<object>
Full Signature
onScroll?UIEventHandler<object>
Full Signature
onScrollCapture?UIEventHandler<object>
Full Signature
onScrollEnd?UIEventHandler<object>
Full Signature
onScrollEndCapture?UIEventHandler<object>
Full Signature
onWheel?WheelEventHandler<object>
Full Signature
onWheelCapture?WheelEventHandler<object>
Full Signature
onAnimationStart?AnimationEventHandler<object>
Full Signature
onAnimationStartCapture?AnimationEventHandler<object>
Full Signature
onAnimationEnd?AnimationEventHandler<object>
Full Signature
onAnimationEndCapture?AnimationEventHandler<object>
Full Signature
onAnimationIteration?AnimationEventHandler<object>
Full Signature
onAnimationIterationCapture?AnimationEventHandler<object>
Full Signature
onToggle?ToggleEventHandler<object>
Full Signature
onBeforeToggle?ToggleEventHandler<object>
Full Signature
onTransitionCancel?TransitionEventHandler<object>
Full Signature
onTransitionCancelCapture?TransitionEventHandler<object>
Full Signature
onTransitionEnd?TransitionEventHandler<object>
Full Signature
onTransitionEndCapture?TransitionEventHandler<object>
Full Signature
onTransitionRun?TransitionEventHandler<object>
Full Signature
onTransitionRunCapture?TransitionEventHandler<object>
Full Signature
onTransitionStart?TransitionEventHandler<object>
Full Signature
onTransitionStartCapture?TransitionEventHandler<object>
Full Signature
aria-activedescendant?string
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
Full Signature
aria-atomic?union
Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
Full Signature
aria-autocomplete?union
Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
presented if they are made.
Full Signature
aria-braillelabel?string
Defines a string value that labels the current element, which is intended to be converted into Braille.
Full Signature
aria-brailleroledescription?string
Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
Full Signature
aria-busy?union
Full Signature
aria-checked?union
Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
Full Signature
aria-colcount?number
Defines the total number of columns in a table, grid, or treegrid.
Full Signature
aria-colindex?number
Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
Full Signature
aria-colindextext?string
Defines a human readable text alternative of aria-colindex.
Full Signature
aria-colspan?number
Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
Full Signature
aria-controls?string
Identifies the element (or elements) whose contents or presence are controlled by the current element.
Full Signature
aria-current?union
Indicates the element that represents the current item within a container or set of related elements.
Full Signature
aria-describedby?string
Identifies the element (or elements) that describes the object.
Full Signature
aria-description?string
Defines a string value that describes or annotates the current element.
Full Signature
aria-details?string
Identifies the element that provides a detailed, extended description for the object.
Full Signature
aria-disabled?union
Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
Full Signature
aria-dropeffect?deprecatedunion
Indicates what functions can be performed when a dragged object is released on the drop target.
Full Signature
aria-errormessage?string
Identifies the element that provides an error message for the object.
Full Signature
aria-expanded?union
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
Full Signature
aria-flowto?string
Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
allows assistive technology to override the general default of reading in document source order.
Full Signature
aria-grabbed?deprecatedunion
Indicates an element's "grabbed" state in a drag-and-drop operation.
Full Signature
aria-haspopup?union
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
Full Signature
aria-hidden?union
Indicates whether the element is exposed to an accessibility API.
Full Signature
aria-invalid?union
Indicates the entered value does not conform to the format expected by the application.
Full Signature
aria-keyshortcuts?string
Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
Full Signature
aria-label?string
Defines a string value that labels the current element.
Full Signature
aria-labelledby?string
Identifies the element (or elements) that labels the current element.
Full Signature
aria-level?number
Defines the hierarchical level of an element within a structure.
Full Signature
aria-live?union
Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
Full Signature
aria-modal?union
Indicates whether an element is modal when displayed.
Full Signature
aria-multiline?union
Indicates whether a text box accepts multiple lines of input or only a single line.
Full Signature
aria-multiselectable?union
Indicates that the user may select more than one item from the current selectable descendants.
Full Signature
aria-orientation?union
Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
Full Signature
aria-owns?string
Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
Full Signature
aria-placeholder?string
Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
A hint could be a sample value or a brief description of the expected format.
Full Signature
aria-posinset?number
Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
Full Signature
aria-pressed?union
Indicates the current "pressed" state of toggle buttons.
Full Signature
aria-readonly?union
Indicates that the element is not editable, but is otherwise operable.
Full Signature
aria-relevant?union
Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
Full Signature
aria-required?union
Indicates that user input is required on the element before a form may be submitted.
Full Signature
aria-roledescription?string
Defines a human-readable, author-localized description for the role of an element.
Full Signature
aria-rowcount?number
Defines the total number of rows in a table, grid, or treegrid.
Full Signature
aria-rowindex?number
Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
Full Signature
aria-rowindextext?string
Defines a human readable text alternative of aria-rowindex.
Full Signature
aria-rowspan?number
Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
Full Signature
aria-selected?union
Indicates the current "selected" state of various widgets.
Full Signature
aria-setsize?number
Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
Full Signature
aria-sort?union
Indicates if items in a table or grid are sorted in ascending or descending order.
Full Signature
aria-valuemax?number
Defines the maximum allowed value for a range widget.
Full Signature
aria-valuemin?number
Defines the minimum allowed value for a range widget.
Full Signature
aria-valuenow?number
Defines the current value for a range widget.
Full Signature
aria-valuetext?string
Defines the human readable text alternative of aria-valuenow for a range widget.
Full Signature
defaultChecked?union
Full Signature
defaultValue?union
Full Signature
suppressContentEditableWarning?union
Full Signature
suppressHydrationWarning?union
Full Signature
accessKey?string
Full Signature
autoCapitalize?union
Full Signature
autoFocus?union
Full Signature
className?string
Full Signature
contentEditable?union
Full Signature
contextMenu?string
Full Signature
dir?string
Full Signature
draggable?union
Full Signature
enterKeyHint?union
Full Signature
hidden?union
Full Signature
id?string
Full Signature
lang?string
Full Signature
nonce?string
Full Signature
slot?string
Full Signature
spellCheck?union
Full Signature
style?object
Full Signature
tabIndex?number
Full Signature
title?string
Full Signature
translate?union
Full Signature
radioGroup?string
Full Signature
role?union
Full Signature
about?string
Full Signature
content?string
Full Signature
datatype?string
Full Signature
inlist?any
prefix?string
Full Signature
property?string
Full Signature
rel?string
Full Signature
resource?string
Full Signature
rev?string
Full Signature
typeof?string
Full Signature
vocab?string
Full Signature
autoCorrect?string
Full Signature
autoSave?string
Full Signature
color?string
Full Signature
itemProp?string
Full Signature
itemScope?union
Full Signature
itemType?string
Full Signature
itemID?string
Full Signature
itemRef?string
Full Signature
results?number
Full Signature
security?string
Full Signature
unselectable?union
Full Signature
popover?union
Full Signature
popoverTargetAction?union
Full Signature
popoverTarget?string
Full Signature
inert?union
Full Signature
inputMode?union
Hints at the type of data that might be entered by the user while editing the element or its contents
Full Signature
is?string
Specify that a standard HTML element should behave like a defined custom built-in element
Full Signature
exportparts?string
Full Signature
part?string
Full Signature
UseDropZoneReturn
State and helper functions returned by the hook.
Property
Specification
isOverunion
Whether a dragged item is currently hovering over the drop zone
Full Signature
isInvalidunion
Whether the currently dragged item violates
accept or multiple rulesFull Signature
filesarray
Array of files from the most recent valid drop
Full Signature
clearFilesfunction
Clears the
files state arrayFull Signature
getRootPropsfunction
Prop getter for binding drag-and-drop handlers directly onto a JSX element
Full Signature
Parameters
userProps?HTMLAttributes<T>