Skip to Content
Kokonut UI

IN-01Inputs

File Upload

A multi-file upload queue with per-file progress, retry and cancel.

Install with
lucide-react, motion

PRONatural Date Input and more like it are in Kokonut UI Pro

Installation

File Upload is a free, open-source React component in the Kokonut UI Inputs collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/file-upload.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/file-upload

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/file-upload.tsx.

npm install lucide-react motion

Usage

import FileUpload from "@/components/kokonutui/file-upload";

export default function Example() {
  return <FileUpload />;
}

Props

onUpload
(file: File, helpers: UploadHelpers) => Promise<void>

Uploads one file. Called once per file, a few at a time. Resolve to mark the row done, reject to show the error with a Retry button. When omitted, uploads are simulated over uploadDelay.

onUploadSuccess
(file: File) => void
onUploadError
(error: FileError, file: File) => void

Called for validation errors and failed uploads.

onComplete
(files: File[]) => void

Called with every uploaded file once nothing is queued or in flight.

onFileRemove
(file: File) => void

Called when a row is removed (cancelling its upload if needed).

acceptedFileTypes
string[]Default built-in

MIME types ("image/png"), wildcards ("image/*") or extensions (".pdf").

maxFileSize
numberDefault built-in

Maximum size of each file in bytes. Defaults to 5 MB.

multiple
booleanDefault true

Accept several files at once. Defaults to true.

maxFiles
numberDefault 5

Maximum number of files in the list. Defaults to 5.

uploadDelay
numberDefault 2000

Simulated upload duration per file in ms, used without onUpload.

simulateFailure
booleanDefault false

Simulated uploads only: the first attempt of every third file fails.

validateFile
(file: File) => FileError | null
className
string

Extra classes for the root element.

UploadHelpers

onProgressrequired
(percent: number) => void

Report upload progress from 0 to 100.

signalrequired
AbortSignal

Aborted when the row is removed or the component unmounts.

FileError

messagerequired
string
coderequired
string

Dependencies

NeedsVersionComes from
lucide-react^0.556.0npm, installed by the CLI
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.