FileDrop
import { FileDrop } from "@study/ui"
Result
Loading...
Live Editor
function Example() { const [names, setNames] = useState([]); return ( <div className="ui-stack"> <FileDrop label="Upload files" hint="Drag here or click · PDF, Word, images · up to 95 MB" accept=".pdf,.docx,image/*" onFiles={(files) => setNames(files.map((f) => f.name))} /> {names.length > 0 && <p>Chosen: {names.join(", ")}</p>} </div> ); }
Variants and states
Light
Dark
When to use
- Where uploading is the task: the Documents tab, an empty folder.
- Otherwise an "Upload" Button with the icon
uploadthat opens a file dialog is enough. - The hint names kind and size – nobody should learn about the 95 MB limit per file only from an error.
Props
| Prop | Type | Default | Meaning |
|---|---|---|---|
label * | ReactNode | – | What to do here, e.g. "Upload files". |
onFiles * | (files: File[]) => void | – | |
accept | string | – | As for `<input type=file>`, e.g. ".pdf,.docx,image/*". |
className | string | – | |
disabled | boolean | – | |
hint | ReactNode | – | Which files and how large, e.g. "PDF, Word, images · up to 95 MB". |
multiple | boolean | true |
Accessibility
- Underneath is a real
<input type="file">: reachable with Tab, Enter opens the dialog. - Drag and drop is an extra, never the only way.