Image Dropzone

Click, drag, or paste target for image files with consumer-owned validation.

Installation

Install with the CLI, or copy the component source into your project.

Add image-dropzone (npm)

npx --yes -p github:itsvigneshv/default-file-ui#main df-ui add image-dropzone

Default

Click, drag, or paste an image into the dropzone.

Drop an image hereor click to browse. Paste also works.PNG, JPG, WEBP, or GIF up to 5 MB

Properties

Click, drag, or paste target for image files. Validation and copy stay with the consumer.

ImageDropzone

PropTypeDefaultNotes
onFile(file: File) => void-Called when a file passes validation (required).
validateFile(file: File) => string | null-Return an error message to reject the file, or null to accept.
onReject(message: string) => void-Called with the rejection message from validateFile.
acceptstringimage/png,image/jpeg,image/webp,image/gifFile input accept attribute.
enablePastebooleantrueListen for image paste on the window while mounted.
disabledbooleanfalseDisable interaction and paste handling.
titleReactNode-Primary label inside the dropzone.
descriptionReactNode-Secondary line under the title.
hintReactNode-Optional tertiary hint (formats, size limits).
iconReactNode-Leading icon. Defaults to ImagePlus.
classNamestring-Additional styles on the button shell.

Tokens

Theme defaults live on :root. Override these globally or on a local host.

TokenTypeDefaultNotes
--df-image-dropzone-min-heightCSS lengthcalc(30 * var(--spacing-unit))Minimum dropzone height.
--radius-lgCSS length-Dropzone corner radius.
--borderCSS color-Dashed border color.
--mutedCSS color-Idle fill.
--primaryCSS color-Active and hover accent.