Options
Return value
Passing
transport additionally returns uploadFile/uploadAll/
cancelUpload/cancelAllUploads/retryUpload — see Upload.
Without transport, none of it exists on the returned object, and
TypeScript won’t let you call it.
getRootProps/getInputProps
Both accept and pass through arbitrary HTML attributes alongside the
recognized handlers — useful for aria-label/aria-describedby/
className/id/data-*. A consumer-supplied style on
getInputProps() is merged, but display: none always wins — it can’t
be overridden, since the hidden native input is load-bearing for
click-to-open.
event.stopPropagation(), the hook’s own handling
for that event is skipped. This is the one supported way to override
built-in behavior.
Click-to-open and keyboard activation
By default,getRootProps() makes the root element click- and
keyboard-activatable: clicking anywhere in the root, or pressing
Space/Enter while it’s focused, opens the native file picker — the same
thing open() does programmatically.
noClick: truedisables click-to-open (keepopen()for a manual “Choose files” button instead).noKeyboard: truedisables Space/Enter-to-open, removestabIndexfrom the returned props, and stops trackingisFocused.noDrag: truedisables drag/drop handling on the root entirely — the input and click-to-open still work.
Things to get right
- Don’t wrap the returned
<input>indisplay: noneyourself and expectopen()to fail —getInputProps()already hides it andopen()calls.click()on it programmatically, which works throughdisplay: nonein all evergreen browsers. - The hook never touches
window/documentduring render, so it’s SSR-safe.isDragGlobal’sdocumentlisteners are registered inside auseEffect(client-only) and removed on unmount. You can render it on the server without guards. - The engine backing one
useMediaDrop()call is created once for that component instance’s lifetime. Changingrestrictions/validatorprops after mount changes future drag-acceptance previews but does not retroactively re-validate files already infiles. - Multiple
useMediaDrop()calls on the same page are independent and safe — see Core concepts. - There’s no dashboard/progress UI to import — every list item, remove button, progress bar, and status message is yours to build.
Core concepts
The file model, the store, and drag state
Types
Every shared type exported from react-mediadrop