Dropzone

Lightweight file drop zone with browse, validation, image previews, and optional progress. Built on native drag and drop — no upload library. Control chrome matches SonoJS rounded-[12px] surfaces.

Gallery

Polished media card: format chips, image dropzone, and simulated upload progress.

Loading…

Installation

CLI
npx @sonojs/ui@latest add dropzone
Also needs
npx @sonojs/ui@latest add button progress
npm i lucide-react

Usage

dropzone.tsx
import { Dropzone } from "@/components/dropzone"

export function Example() {
  return (
    <Dropzone
      accept="image/png,image/jpeg,application/pdf"
      maxSize={5 * 1024 * 1024}
      maxFiles={5}
      multiple
    />
  )
}

Props

PropTypeDefaultDescription
valueDropzoneFile[]-Controlled file list.
defaultValueDropzoneFile[][]Initial files when uncontrolled.
onValueChange(files: DropzoneFile[]) => void-Fires when the file list changes.
onReject(rejections: DropzoneRejection[]) => void-Fires for files rejected by type, size, or maxFiles.
acceptstring-HTML accept string, e.g. `image/*,application/pdf`.
maxSizenumber-Max bytes per file.
maxFilesnumberInfinityMax files allowed in the list.
multiplebooleantrueAllow selecting more than one file at a time.
disabledbooleanfalseDisables the zone and remove actions.
labelstring"Drop files here or browse"Primary text inside the drop zone.
descriptionstring-Hint under the label. Defaults from accept / maxSize / maxFiles.
classNamestring-Merge Tailwind classes on the root.