Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

File Dropzone

A drag-and-drop file surface with click and keyboard to browse, built on native DnD.

Click to upload or drag and drop

Installation

npx logic2b@next add file-dropzone

Usage

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.

Generated JSX
<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.

View JSON

FileDropzoneProps

Type
interface 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

Component

A 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
PropTypeRequiredDefaultDescription
onFiles(files: File[]) => voidNo—Called with the accepted files when they are dropped or selected.
acceptstringNo—`accept` attribute forwarded to the file input (e.g. `"image/*"`).
multiplebooleanNofalseAllow selecting more than one file. Default `false`.
disabledbooleanNo——
inputLabelstringNo"Upload files"Accessible name for the native file input. Default `"Upload files"`.
childrenReact.ReactNodeNo—Replace the default icon/prompt with your own content.

Accessibility contract

Machine-readable behavior and consumer responsibilities for file-dropzone.

View JSON
Support
Authored behavior
Pattern
file upload
HTMLInputElement type=file
Keyboard interactions for file-dropzone
KeysBehavior
Enter SpaceActivate 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.