Skip to content
Back

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
MCP
  • Q3 board deck.pdf
    4.0 MB · Starting…
  • revenue-by-region.csv
    371 KB · Starting…
  • hero-shot.png
    2.5 MB · Starting…
  • contract-final-fail.docx
    1.0 MB · Starting…
Dioxus
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.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add file-dropzone
Rust
use 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

Dioxus · rust
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.pdf
    4.0 MB · Starting…
  • revenue-by-region.csv
    371 KB · Starting…
  • hero-shot.png
    2.5 MB · Starting…
  • contract-final-fail.docx
    1.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.

  • PDF
    Q3 board deck.pdf
    4.0 MB · Starting…
  • CSV
    revenue-by-region.csv
    371 KB · Starting…
  • PNG
    hero-shot.png
    2.5 MB · Starting…
  • DOCX
    contract-final-fail.docx
    1.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

PropTypeDefaultDescription
labelString"Add files"Main prompt.
descriptionString"Drop files here or choose from your device"Second line.
noteOption<String>Default::default()Small line under it (defaults to the accepted types, size and file limit).
drop_labelString"Drop to upload"Label while files hover.
acceptStringDefault::default()Accept list (".pdf, image/*").
max_sizeOption<u64>Default::default()Largest file in bytes.
max_filesOption<usize>Default::default()Most files kept.
multiplebooltrueSeveral files (a new file replaces the old one when false).
variantString"plain"`plain` · `fan`.
list_placementString"below"`below` · `inside`.
compact_atOption<usize>Default::default()Fold the prompt to a slim bar once the list holds this many files.
presetVec<(String, u64)>Default::default()Rows present at mount (name, bytes), already uploaded.
autoplayboolDefault::default()Play a sample drop of four files.
disabledboolDefault::default()Disabled.
nowrequiredClockMs—Shared clock (progress).
on_changeEventHandler<Vec<String>>—Names in the list whenever it changes.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
TabThe file picker, then each row's Retry and Remove
EnterorSpaceOpen the picker
↑or↓Same action on the next row
DeleteorBackspaceRemove 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 FileDropzone from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: FileDropzoneEl in oxyn_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.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI