Skip to content
Thrum

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-upload

This 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
type FileUploadItem = {
  id: string;
  name: string;
  size: number; // bytes
  type?: string;
  status: "queued" | "uploading" | "done" | "error";
  progress?: number | null; // 0 to 100
  error?: string;
};
Sample
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

PropTypeDefaultDescription
filesreadonly 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.
acceptstring–The types the picker offers and a drop accepts, as in the input's accept: ".pdf,image/*".
multiplebooleanDefault trueTake several files at a time. Without it only the first of a drop is taken.
maxSizenumber–The largest file, in bytes.
maxFilesnumber–The most files in the list, counting those already in files.
titlestringDefault "Drop files here or browse"The drop area's main line, and the input's name.
hintstring–The line under it. By default it is built from accept, maxSize and maxFiles.
disabledbooleanDefault falseTurns the drop area off. Files already listed stay, with their buttons.
idstring–The file input's id, for a label elsewhere on the page.
namestring–The file input's name, when the drop area sits in a form.
localestringDefault "en-US"The locale that writes sizes and percentages.
soundbooleanDefault truePlay 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.
classNamestring–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.
KeysAction
TabReach the drop area. The focus ring goes round the whole area.
Enter / SpaceOpen the system's file picker.
TabThen move through each file's retry and remove buttons.

Source

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor