Installation
npx logic2b@next add file-dropzoneUsage
import { FileDropzone } from "@/components/ui/file-dropzone"
<FileDropzone
inputLabel="Upload product images"
multiple
accept="image/*"
onFiles={(files) => upload(files)}
/>
It highlights while a file is dragged over it and calls onFiles with the
dropped or selected File[]. Rendering the file list, previews and upload
progress is left to you — pass your own content as children to replace the
default icon and prompt.
Accessibility
The surface is a role="button" region, focusable and operable with
Enter / Space to open the file picker, so it works without
a mouse. A labelled native <input type="file"> is rendered alongside the
surface, outside the button region, so native file selection works without
nested interactive controls. Use inputLabel to describe the upload purpose.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
<FileDropzone
accept="image/*"
multiple
inputLabel="Upload project images"
className="w-full max-w-md"
/>API reference
Generated from the public TypeScript exports in src/ui/file-dropzone.tsx.
FileDropzoneProps
Typeinterface FileDropzoneProps extends Omit<React.ComponentProps<"div">, "onDrop" | "children"> { /** Called with the accepted files when they are dropped or selected. */ onFiles?: (files: File[]) => void /** `accept` attribute forwarded to the file input (e.g. `"image/*"`). */ accept?: string /** Allow selecting more than one file. Default `false`. */ multiple?: boolean disabled?: boolean /** Accessible name for the native file input. Default `"Upload files"`. */ inputLabel?: string /** Replace the default icon/prompt with your own content. */ children?: React.ReactNode }FileDropzone
ComponentA drag-and-drop file surface with click / keyboard to browse. Native DnD (no dependencies): highlights while a file is dragged over it and calls `onFiles` with the dropped or selected files. Rendering the file list is left to the consumer.
Props: FileDropzoneProps| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
onFiles | (files: File[]) => void | No | — | Called with the accepted files when they are dropped or selected. |
accept | string | No | — | `accept` attribute forwarded to the file input (e.g. `"image/*"`). |
multiple | boolean | No | false | Allow selecting more than one file. Default `false`. |
disabled | boolean | No | — | — |
inputLabel | string | No | "Upload files" | Accessible name for the native file input. Default `"Upload files"`. |
children | React.ReactNode | No | — | Replace the default icon/prompt with your own content. |
Accessibility contract
Machine-readable behavior and consumer responsibilities for file-dropzone.
- Support
- Authored behavior
- Pattern
- file upload
- HTMLInputElement type=file
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
Built-in semantics
- A hidden native file input owns the picker; the visible drop surface is keyboard activatable.
Consumer responsibilities
- Provide contextual instructions, accepted formats and validation feedback.