File upload
Takes files by drop or browse, shows each upload and what failed, then the attached files.
Drop files here
PDF, images, CSV · up to 10 MB
Installation
npm i @uisatin/uiimport { FileUpload, type FileUploadFile } from '@uisatin/ui/file-upload'About 38.1 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/file-upload.jsonAdds file-upload.tsx, attachment.tsx, button.tsx, labels.tsx, progress.tsx and spinner.tsx to components/ui and installs iconoir-react.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The FileUpload component renders a drop zone with a Browse files button over a hidden <input type="file">, then a list of the files the app is handling. Dropped and picked files are checked against accept and maxSize; the upload itself is yours, kept in files.
| Prop | Type | Default |
|---|---|---|
files | FileUploadFile[] | [] |
accept | string | — |
maxSize | number | — |
multiple | boolean | true |
disabled | boolean | false |
title | ReactNode | "Drop files here" |
dropTitle | ReactNode | "Drop to upload" |
description | ReactNode | — |
browseLabel | string | "Browse files" |
onBrowse | () => void | — |
onFilesAdded | (files: File[]) => void | — |
onFilesRejected | (rejections: FileUploadRejection[]) => void | — |
onCancel | (file: FileUploadFile) => void | — |
onRemove | (file: FileUploadFile) => void | — |
onOpen | (file: FileUploadFile) => void | — |
className | string | — |
ref | Ref<HTMLDivElement> | — |
...props | ComponentProps<'div'>Other attributes go to <div> | — |
Accessibility
Dropping files works by pointer only; Browse files is a native button that opens the file picker, described by description, so keyboard users get the same path. The rows are lists named "Files" and "Attached files". An uploading row has a Progress named "Uploading <name>" and a "Cancel <name>" button; an error row is role="alert", so it is read out when it appears, with a "Remove <name>" button. Rejected files are only reported to onFilesRejected; show them as error rows so they are announced.
| Key | Action |
|---|---|
| EnterorSpace | On Browse files: opens the file picker. |
Something wrong or missing on this page?
Report a problemSuggest an improvement