Kibo UI
Header Background

Dropzone

Dropzone is a component that allows you to drag-and-drop files into a container to process them.

Installation

npx kibo-ui@latest add dropzone

Features

  • Drag and drop files to upload
  • Customize the empty state and content
  • Intelligently handle file types, sizes, and counts
  • Show file names and sizes in a human readable format
  • Handle errors and reject files
  • Disable the dropzone when needed
  • Customize the appearance with className
  • Show file previews for images
  • Replace existing files by dragging new ones
  • Context provider for accessing dropzone state

Examples

With max and min sizes

Multiple files

Images only

With custom empty state

Showing an image preview

Props

The dropzone component is made up of the following subcomponents:

Dropzone

PropTypeDefault
multiple
boolean
-
onDragEnter
DragEventHandler<HTMLElement>
-
onDragOver
DragEventHandler<HTMLElement>
-
onDragLeave
DragEventHandler<HTMLElement>
-
accept
Accept
-
minSize
number
-
maxSize
number
-
maxFiles
number
-
preventDropOnDocument
boolean
-
noClick
boolean
-
noKeyboard
boolean
-
noDrag
boolean
-
noDragEventsBubbling
boolean
-
disabled
boolean
-
onDropAccepted
<T extends File>(files: T[], event: DropEvent) => void
-
onDropRejected
(fileRejections: FileRejection[], event: DropEvent) => void
-
getFilesFromEvent
(event: DropEvent) => Promise<(File | DataTransferItem)[]>
-
onFileDialogCancel
() => void
-
onFileDialogOpen
() => void
-
onError
(err: Error) => void
-
validator
<T extends File>(file: T) => FileError | readonly FileError[] | null
-
useFsAccessApi
boolean
-
autoFocus
boolean
-
src
File[]
-
className
string
-
onDrop
(acceptedFiles: File[], fileRejections: FileRejection[], event: DropEvent) => void
-
children
ReactNode
-

DropzoneEmptyState

PropTypeDefault
children
ReactNode
-

DropzoneContent

PropTypeDefault
children
ReactNode
-

On this page