File dropzone
A generous target for files: rows upload with progress and time left, fail with a reason and Retry, collapse when removed; rejected types and sizes keep their reason; the prompt can fold to a slim bar.
oxyn add file-dropzone- Q3 board deck.pdf4.0 MB · Starting…
- revenue-by-region.csv371 KB · Starting…
- hero-shot.png2.5 MB · Starting…
- contract-final-fail.docx1.0 MB · Starting…
rsx! {
FileDropzone {
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(5),
autoplay: true,
now: clock.now(),
}
}Rendered from Rust at build time · goes live when visible
When to use
- A generous target for one or more files and the list that follows.
- Files are checked against accept (".pdf, image/*") and max_size: a rejected file keeps a row with its reason and never uploads; past max_files extra files are refused with a note.
- Each accepted file uploads with progress and time left ("1.2 MB of 4.0 MB · 3 s left"), fails with a reason and Retry, or settles with a check; Remove collapses the row (and aborts). variant: fan fans three documents over the target while files hover and gives rows type badges; plain (Arc) lifts the icon. list_placement: inside puts rows inside the target's edge; compact_at folds the prompt to a slim bar once the list holds that many. preset rows render without an entrance; autoplay plays a sample drop of four files (one fails). multiple: false replaces the file.
When not to use
- On or off for things that apply right away: use Switch instead.
- A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself: use Checkbox instead.
- Pick one: use Radio group instead.
Installation
File dropzone is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add file-dropzoneuse crate::oxyn::{FileDropzone, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{FileDropzone, STATUS_INDICATOR_CSS};
Usage
rsx! {
FileDropzone {
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(5),
autoplay: true,
now: clock.now(),
}
}Examples
Autoplay
A sample drop of four files: progress, time left, one failure with Retry.
- Q3 board deck.pdf4.0 MB · Starting…
- revenue-by-region.csv371 KB · Starting…
- hero-shot.png2.5 MB · Starting…
- contract-final-fail.docx1.0 MB · Starting…
Code
rsx! {
FileDropzone {
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(5),
autoplay: true,
now: clock.now(),
}
}Fan
Documents fan out, type badges.
- PDFQ3 board deck.pdf4.0 MB · Starting…
- CSVrevenue-by-region.csv371 KB · Starting…
- PNGhero-shot.png2.5 MB · Starting…
- DOCXcontract-final-fail.docx1.0 MB · Starting…
Code
rsx! {
FileDropzone {
variant: "fan",
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(5),
autoplay: true,
now: clock.now(),
}
}Folding
Rows inside the edge; the prompt folds at two files.
Code
rsx! {
FileDropzone {
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(5),
list_placement: "inside",
now: clock.now(),
}
}Single
One file: a new one replaces the old.
Code
rsx! {
FileDropzone {
accept: ".pdf,.csv,.docx,image/*",
max_size: Some(25 * 1024 * 1024),
max_files: Some(1),
now: clock.now(),
}
}API reference
FileDropzone
| Prop | Type | Default | Description |
|---|---|---|---|
label | String | "Add files" | Main prompt. |
description | String | "Drop files here or choose from your device" | Second line. |
note | Option<String> | Default::default() | Small line under it (defaults to the accepted types, size and file limit). |
drop_label | String | "Drop to upload" | Label while files hover. |
accept | String | Default::default() | Accept list (".pdf, image/*"). |
max_size | Option<u64> | Default::default() | Largest file in bytes. |
max_files | Option<usize> | Default::default() | Most files kept. |
multiple | bool | true | Several files (a new file replaces the old one when false). |
variant | String | "plain" | `plain` · `fan`. |
list_placement | String | "below" | `below` · `inside`. |
compact_at | Option<usize> | Default::default() | Fold the prompt to a slim bar once the list holds this many files. |
preset | Vec<(String, u64)> | Default::default() | Rows present at mount (name, bytes), already uploaded. |
autoplay | bool | Default::default() | Play a sample drop of four files. |
disabled | bool | Default::default() | Disabled. |
nowrequired | ClockMs | — | Shared clock (progress). |
on_change | EventHandler<Vec<String>> | — | Names in the list whenever it changes. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | The file picker, then each row's Retry and Remove |
| EnterorSpace | Open the picker |
| ↑or↓ | Same action on the next row |
| DeleteorBackspace | Remove the focused row |
Accessibility
- The picker input carries the label, description and limits.
- Failed rows announce their reason (role=alert); progress bars are role=progressbar.
From the spec
- The picker input carries the label, description and limits; failed rows are role=alert; bars are role=progressbar.
Motion & interaction
Timing
- Rows enter 320 ms; documents fan 380 ms spring; progress eases 250 ms.
- Reduced motion replaces height and lift animations with fades and keeps progress instant.
Responsive behaviour
- Fills its container; names truncate.
Edge cases (spec)
- Fills its container; names truncate.
Notes for AI
- Import
FileDropzonefromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
FileDropzoneElinoxyn_gpui. - Props to set first:
now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.