Forms
File Upload
Uploads files via drag-and-drop or system file picker with validation, status presentation, and removal. Applications own transport and retries.
Usage
Anatomy
The parts and how they nest, taken from the preview above.
Examples
Drag and drop files here
Error and retry
Simulates a failed upload. Retry the same file without selecting it again.
Disabled upload
Enable selection, then disable the selected upload to check paused progress and blocked actions.
Recommendations
| Guidance | Practice |
|---|---|
| Do | Show accepted formats and size limits before selection. Keep rejection reasons and progress beside each file. |
Usage boundaries
| Guidance | Boundary |
|---|---|
| Scope | The application owns transport, cancellation, and retries. Validate file content and limits on the server. |
API reference
Public props from @mizen-labs/ui. Use exported prop types for the complete TypeScript contract.
| Prop | Type | Default | Description |
|---|---|---|---|
| | — | Accepted file types specifier string matching file extensions or MIME patterns. |
| | [] | Initial files array for uncontrolled file upload presentation. |
| | false | Disables user interaction across picker trigger, dropzone, and remove actions. |
| | 1 | Maximum number of files allowed in the upload collection. |
| | — | Maximum allowed file size in bytes for each uploaded file. |
| | — | Field name submitted with form data on the synchronized native file input. |
| | — | Controlled array of files. |
| | — | Callback fired when files are added, dropped, or removed with change details. |
| | — | Callback fired when files are rejected due to type, size, or count constraints. |
| | "div" | Root container providing file upload context, drag-and-drop coordination, and accessibility announcements. |
| | "div" | Non-interactive drag-and-drop surface receiving files without pretending to be keyboard-focusable. |
| | "input" | Visually hidden native input element synchronized with selected files for form submission. |
| | "button" | Accessible button element opening the native system file picker. |
| | "ul" | List container supporting children or a render function. Set layout="tiles" for a horizontal attachment strip; defaults to rows. |
| | "li" | Scopes file data and index for an item. Set layout="upload" for a compact upload card, or layout="tile" for compact attachments. Defaults to row. |
| | Optional | Shows a local image preview with object URL cleanup. Children provide the document or failed-image fallback. |
| | "span" | Displays the file name with automatic ellipsis truncation. |
| | "span" | Displays the formatted file size with tabular figures. |
| | "span" | Renders and announces pending, uploading, success, or error states. Error status also marks the file card border. |
| | "div" | Renders a standard progress bar inside each file card. Applications own transport and progress updates. |
| | "button" | Accessible button to remove a file from the list with focus restoration. |