File upload tile that sinks under the dragged file; the drop point stretches into a chip whose rim traces the upload progress.
DragDrag
Expense report · ER-1042
€ 186.40
dropzone, lively
Use it wherever people attach files in a product: receipts on an expense report, a CSV import, product images, attachments in a reply. It validates type, size and count, keeps the list of files and shows the upload you drive. For a single image with a crop step, or a full asset manager with folders, build on top of it rather than stretching it.
The tile is charged by the file. While a file hovers, the tile sinks under it, its icon ball lifts and turns
to your primary, and the dashed rim runs toward the pointer (charge). On drop a 6 px ball appears
where the file fell and stretches into the file's chip, which flies into the list while the other chips
make room (action). The chip's rim then fills clockwise as progress grows; at 100% the leading ball
squashes, takes the color and draws a check (settle). Picked files leave from the icon ball that opened
the picker, so the keyboard path gets the same moment.
pnpm dlx shadcn@latest add @motionkit-pro/dropzonenpx shadcn@latest add @motionkit-pro/dropzoneyarn dlx shadcn@latest add @motionkit-pro/dropzonebunx --bun shadcn@latest add @motionkit-pro/dropzoneRequires a Pro license and the @motionkit-pro registry with your token. See Installation.
It depends on motion only. There is no upload library inside: you upload the files and report
status and progress back.
import { useState } from "react"
import { Dropzone, type DropzoneFile } from "@/components/ui/dropzone"
export function Receipts() {
const [files, setFiles] = useState<DropzoneFile[]>([])
return (
<Dropzone
value={files}
onValueChange={setFiles}
accept="application/pdf,image/*"
maxSize={10_000_000}
maxFiles={6}
hint="PDF, JPG or PNG · up to 10 MB"
onDrop={(added, rejections) => {
for (const item of added) upload(item, setFiles)
}}
/>
)
}
// Report progress by replacing the file in the list.
function upload(
item: DropzoneFile,
setFiles: (fn: (files: DropzoneFile[]) => DropzoneFile[]) => void,
) {
const update = (patch: Partial<DropzoneFile>) =>
setFiles((files) => files.map((f) => (f.id === item.id ? { ...f, ...patch } : f)))
update({ status: "uploading", progress: 0 })
// ...your request: update({ progress: loaded / total }), then update({ status: "done" })
// or update({ status: "error", error: "Network error" })
}Each file is { id, file, status, progress?, error? } with status one of ready, uploading, done
or error. New files arrive as ready. onDrop(added, rejections) fires on every drop or pick, with the
rejected files and their reason (type, size, count); the component also shows the first message under
the tile. Pass name to keep the native input's FileList in step for plain form posts. ref points at
that input. multiple={false} makes a new file replace the current one.
Three layout presets share one look and one motion:
<Dropzone preset="card" /> {/* 160 px tile, chips below (default) */}
<Dropzone preset="inline" /> {/* one field-height row, chips inside, "Attach files" */}
<Dropzone preset="page"> {/* the whole container is the target */}
<MediaGrid />
<DropzoneList />
</Dropzone>Compose the parts yourself when you need a different order: DropzoneArea (the tile or row),
DropzoneList (the chips, or renderItem), DropzoneItem (one chip) and DropzoneBrowse (a picker
button for the page preset). Your onDragEnter, onDragOver, onDragLeave and onDrop on the area
run first and never replace the component's own.
Set the character for the whole app with MotionKitProvider, or per dropzone with temperament. At
calm the sink is barely there, the dashes glide and the chip lands without overshoot.
Prop
Type
Also accepts all props of Omit<
ComponentProps<"div">,
"ref" | "onDrop" | "title" | "defaultValue" | "onChange"
>.
Prop
Type
Also accepts all props of Omit<
ComponentProps<"button">,
| "title"
| "onAnimationStart"
| "onAnimationEnd"
| "onAnimationIteration"
| "onDrag"
| "onDragStart"
| "onDragEnd"
| "onDragEnter"
| "onDragOver"
| "onDragLeave"
| "onDrop"
>.
Prop
Type
Also accepts all props of ComponentProps<"ul">.
Prop
Type
The inline preset is one 36 px row, the same rim as a text field. Chips sit inside it, tag-input style,
and the ball-to-chip morph happens in the row. The row sinks and draws its dashed rim while a file hovers.
DragDrag
Ticket #2291 · Priority high
dropzone, lively
The page preset makes the whole container the target. Dragging a file over it dims the page, draws a
dashed rim inside its edge and grows a tile out of the point where the file entered. Upload chips appear
above the grid; DropzoneBrowse opens the picker from the toolbar.
DragDrag
Media library · Spring campaign
Drag images anywhere on the library to upload
dropzone, lively
<button> named by its title ("Drop files here or browse"); Enter or Space opens the
native picker. The native <input type="file"> is visually hidden and out of the tab order; name,
accept, multiple and disabled are set on it.listitem whose name reads the file
name, size and state ("receipt-0412.pdf, 212 KB, uploaded"), with a Remove {name} button whose hit
area is at least 24 px.role="progressbar" per chip with aria-valuenow from 0 to 100.role="alert" under the tile.aria-hidden.ring on the tile, the Attach button and each chip. Colors come from your theme
(primary, muted, destructive, ring, input), so contrast follows it in light and dark.| Key | Action |
|---|---|
| Enter / Space (on the tile or Attach) | Opens the file picker |
| Tab | Moves between the tile, the chips and the rest of the form |
| Arrow keys (on a chip) | Moves focus to the previous or next chip |
| Backspace / Delete (on a chip) | Removes the file; focus goes to the next chip or the browse one |
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing disappears.
The tile does not sink and the dashes stay still, but the rim, icon ball and text still change color and
words while a file hovers. A new chip fades in at its place in the list instead of flying from the drop
point, the progress rim changes its extent in a 120ms fade, and the check fades in. At rest it is the same
finished dropzone: dashed rim, inner highlight and chips.
stroke-dashoffset on one small SVG.transform and opacity. The flight is a
shared-layout morph measured once, after the list has the new chip, so the destination is exact while
the other chips reflow.pathLength on an SVG rect; text uses tabular figures so the percentage
never shifts the row.dragenter/dragleave are counted so moving over children never flickers the state; the pointer
position updates state only when it moves by a pixel or more.Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
drag, press, keyboard focus
No sink, no running dashes and no flight: chips fade in at their place in the list, the progress rim changes its extent in a 120ms fade and the check fades in.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)