File upload
A drop area around a real file input, with the list of chosen files and their progress. It checks type, size and count and says why a file was turned away; the upload itself is yours, and the list shows the state you pass. For a single small file in a form, a plain file input is enough.
Install
npx shadcn@latest add @thrum-pro/file-uploadThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons circle-alert, circle-check, file, refresh, upload and x from the icon set.
Data shape
type FileUploadItem = {
id: string;
name: string;
size: number; // bytes
type?: string;
status: "queued" | "uploading" | "done" | "error";
progress?: number | null; // 0 to 100
error?: string;
};const files = [
{ id: "a1", name: "Price list.csv", size: 48200, status: "done" },
{ id: "a2", name: "Q4 board deck.pdf", size: 2480000, status: "uploading", progress: 42 },
{ id: "a3", name: "Floor plan.png", size: 3140000, status: "error", error: "Connection lost" },
];Props
| Prop | Type | Default | Description |
|---|---|---|---|
files | readonly FileUploadItem[] | Default [] | The files to list, with their status and progress. The component never uploads; it shows what you pass. |
onFilesAdd | (files: File[]) => void | – | Called with the files that passed every check, from the picker or a drop. Add them to files and start their upload. |
onFilesReject | (rejections: { file: File; reasons: string[] }[]) => void | – | Called with the files that were turned away and why. They are also listed under the drop area until the next pick. |
onRemove | (id: string) => void | – | Called with a file's id when its remove button is pressed. Without it there is no remove button. |
onRetry | (id: string) => void | – | Called with a failed file's id when its retry button is pressed. Without it there is no retry button. |
accept | string | – | The types the picker offers and a drop accepts, as in the input's accept: ".pdf,image/*". |
multiple | boolean | Default true | Take several files at a time. Without it only the first of a drop is taken. |
maxSize | number | – | The largest file, in bytes. |
maxFiles | number | – | The most files in the list, counting those already in files. |
title | string | Default "Drop files here or browse" | The drop area's main line, and the input's name. |
hint | string | – | The line under it. By default it is built from accept, maxSize and maxFiles. |
disabled | boolean | Default false | Turns the drop area off. Files already listed stay, with their buttons. |
id | string | – | The file input's id, for a label elsewhere on the page. |
name | string | – | The file input's name, when the drop area sits in a form. |
locale | string | Default "en-US" | The locale that writes sizes and percentages. |
sound | boolean | Default true | Play a sound when files are added or removed, an error sound when every file of a pick is turned away, and a success sound when the last file is done. |
className | string | – | Classes for the root element. It fills its container. |
Motion and sound
Motion
- The drop area takes its hover and dragging colours over 150 ms.
- A progress fill slides to each new share over 200 ms.
- Reduced motion: colours and fills change at once.
Sound
- A soft rising sound when files are added, once per pick or drop.
- A soft falling sound when a file is removed.
- An error sound when every file of a pick is turned away.
- A two-note rise when the last file in the list is done.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The drop area is a label around a real file input, so the input is named by the area's text and works with the keyboard, a screen reader and voice control.
- Rejections are listed in a polite live region, each with the file's name and every reason.
- Each file is a list item; its progress bar is named Upload of and the file's name, with the percentage as its value text.
- Done and failed are words and icons, never colour alone. Retry and remove buttons are named with the file's name.
- A long file name is cut with an ellipsis and keeps its full text in a tooltip. Nothing overflows at 160 pixels wide.
| Keys | Action |
|---|---|
| Tab | Reach the drop area. The focus ring goes round the whole area. |
| Enter / Space | Open the system's file picker. |
| Tab | Then move through each file's retry and remove buttons. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/file-upload.tsx- Packages
- None
- Brings along
- Sound engineButton
- Icons
circle-alertcircle-checkfilerefreshuploadx
Changelog
- 1.0.0 · 2026-12-03First release.