A drop area and a managed list in one card. Each file gets a type badge and a row that shows progress with the time left, then ends done, failed with Retry, or rejected with the reason. Uploads run through your own function, a few at a time.
On this page
- Attach files to a brief or a ticket
- Upload a batch of receipts
- Add source documents to a knowledge base
- Send assets for review
Examples
Types, size and count
Your own upload
Controlled
Installation
npx knowns-ui@latest add uploaderPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Uploader from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/uploader
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add uploader
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/progress.tsx
- components/ui/knowns/file-drop.tsx
- components/ui/knowns/file-drop-utils.ts
- components/ui/knowns/uploader/uploader.tsx
- components/ui/knowns/uploader/uploader-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/uploader, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "uploader" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- onUpload
(file, onProgress, signal) => Promise- Default
simulated - Sends one file. Call onProgress with 0 to 100, resolve when it is stored, reject to fail the row (the error's message is shown). Abort when signal fires. Left out, a simulated upload runs.
- accept
string- Same syntax as <input accept>: ".pdf,image/*". Also filters the picker.
- maxSize
number- Bytes. A larger file is listed as rejected: Too large, max 25 MB.
- maxFiles
number- Rows the list holds, rejected ones aside. Files past it are listed as rejected.
- concurrency
number- Default
3 - Uploads at once. The rest wait in the queue, in the order they were added.
- items / defaultItems
UploadItem[]- The list, controlled (with onChange) or as a start. A row: { id, file, name, size, status, progress, error? }.
- onChange
(items) => void- Every change: added, progress, done, failed, retried, removed, cleared.
- hint
ReactNode- Default
from the rules - The drop area's second line, e.g. PDF, DOCX, Images up to 10 MB, 6 files max.
- label
ReactNode- Default
"Drop files here or browse" - The drop area's main line at rest. While files are held over it, it says Drop 3 files.
- autoplay
boolean- Default
false - Plays a sample drop of four files once it scrolls into view. Your onUpload is not called for them, and the live region stays quiet until a person acts.
- disabled
boolean- Default
false - The drop area and the picker are off.
- className
string- On the card.
| Prop | Type | Default | Description |
|---|---|---|---|
| onUpload | (file, onProgress, signal) => Promise | simulated | Sends one file. Call onProgress with 0 to 100, resolve when it is stored, reject to fail the row (the error's message is shown). Abort when signal fires. Left out, a simulated upload runs. |
| accept | string | - | Same syntax as <input accept>: ".pdf,image/*". Also filters the picker. |
| maxSize | number | - | Bytes. A larger file is listed as rejected: Too large, max 25 MB. |
| maxFiles | number | - | Rows the list holds, rejected ones aside. Files past it are listed as rejected. |
| concurrency | number | 3 | Uploads at once. The rest wait in the queue, in the order they were added. |
| items / defaultItems | UploadItem[] | - | The list, controlled (with onChange) or as a start. A row: { id, file, name, size, status, progress, error? }. |
| onChange | (items) => void | - | Every change: added, progress, done, failed, retried, removed, cleared. |
| hint | ReactNode | from the rules | The drop area's second line, e.g. PDF, DOCX, Images up to 10 MB, 6 files max. |
| label | ReactNode | "Drop files here or browse" | The drop area's main line at rest. While files are held over it, it says Drop 3 files. |
| autoplay | boolean | false | Plays a sample drop of four files once it scrolls into view. Your onUpload is not called for them, and the live region stays quiet until a person acts. |
| disabled | boolean | false | The drop area and the picker are off. |
| className | string | - | On the card. |
Keyboard
- Tab reaches the drop area; Enter or Space opens the file picker.
- Tab then moves through each row's Retry and Remove, and the footer's Clear.
Accessibility
- The drop area is a button, described by the hint (the accepted types, the size and the count), so a screen reader hears the rules before picking.
- Each uploading row has a progressbar named after the file, with its value.
- Retry and Remove are named after the file (Retry march-ledger.xlsx, Cancel renewal-terms.pdf while it uploads).
- One polite live region says when a file is uploaded, failed and why, or not added and why; progress ticks are not read out. While autoplay runs by itself it stays quiet.
- The type badge is decoration: the file name carries the type. A rejected or failed row says why in words, not only in colour.
What it handles
- 01Counts the files held over the area and says it (Drop 3 files), with the outline and a faint wash in the ring colour and the three sheets of the icon fanning out.
- 02Checks each file against accept, maxSize and the room left under maxFiles, and lists the ones that do not fit as rejected rows with the reason (Too large, max 25 MB), so nothing disappears without a word.
- 03Sends files through your onUpload a few at a time (concurrency, default 3) and queues the rest; a rejected promise fails the row with its message and Retry calls onUpload again.
- 04Works out the time left from a smoothed upload rate, so the estimate does not jump on every progress event.
- 05Aborts a running upload when its row is removed or the uploader unmounts, through the AbortSignal it hands to onUpload.
- 06Keeps the footer count (2 of 4 uploaded, 1 failed) and a Clear that removes finished, failed and rejected rows but never a running one.
States
- First render
- Nothing moves; rows given in items or defaultItems paint as they are
- none
- Files held over the area
- The outline and wash take the ring colour; the back sheets fan out 14 degrees and the front one lifts
- 280ms, ease in out
- Files dropped
- Rows rise in one after another, 45ms apart and 240ms at most for the batch
- 180ms each, ease out
- Progress
- The bar eases to each new value
- 280ms, ease in out
- Row removed or cleared
- It folds away
- 120ms, ease out
- Reduced motion
- No fan, no rise; rows and bars change at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing moves; rows given in items or defaultItems paint as they are | none |
| Files held over the area | The outline and wash take the ring colour; the back sheets fan out 14 degrees and the front one lifts | 280ms, ease in out |
| Files dropped | Rows rise in one after another, 45ms apart and 240ms at most for the batch | 180ms each, ease out |
| Progress | The bar eases to each new value | 280ms, ease in out |
| Row removed or cleared | It folds away | 120ms, ease out |
| Reduced motion | No fan, no rise; rows and bars change at once | 0ms |
Works with
When to use
When to use
- A batch of files sent to your server: the queue, progress with time left, Retry and the reasons for rejected files, managed for you.
- A form that waits until every attachment is in, with the list in your own state.
When not to use
- Your own upload list built from the parts: use File Drop.
- Files attached to a prompt: use Chat Composer.
- One spreadsheet read before an import: use Import Upload.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Uploader to my app and wire it to my own data.
- I need a batch of files sent to your server: the queue, progress with time left, Retry and the reasons for rejected files, managed for you. Set that up with the Knowns UI Uploader.
- Which Uploader props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "uploader" }) and search_docs({ query: "uploader" }).