Forms
DropZone
Drag-and-drop target that highlights while files are dragged over it.
import { DropZone, DropZoneGrid } from "datui";Examples
Drop or browse
With onFiles the zone also opens the file dialog on click, Enter or Space.
Drop target only
No files yet
Accessibility
- With
onFilesthe zone isrole="button", focusable, and Enter/Space/click open the file dialog; give itaria-label. - Without
onFilesit is a pure drop target: pair it withFileso keyboard users can add files. - Announce results yourself, e.g. with an
aria-liveregion.
API
DropZone
Drop target that highlights while files are dragged over it.
| Prop | Type | Default | Description |
|---|---|---|---|
| accept | string | — | File types for the dialog (with `onFiles`). |
| children | ReactNode | ((state: { active: boolean; }) => ReactNode) | — | Content, or a render function receiving the drag-over state. |
| className | string | — | |
| disabled | boolean | — | |
| multiple | boolean | — | Allow several files (with `onFiles`). |
| onFiles | ((files: File[]) => void) | — | Makes the zone a button that opens the file dialog on click / Enter / Space, and receives dropped files. Without it the zone is a pure drop target (pair it with `File` for keyboard users). |
DropZoneGrid
Lays out several DropZones.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| direction | "row" | "column" | row | `row` places zones side by side from the tablet breakpoint (stacked below it). |