Xzero UI
Pro library

File upload

A complete file selection flow with constraints, progress, and error feedback.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/file-upload
Live · keyboard ready

Use it for documents or media when people need to see upload progress and recover from invalid files.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/file-upload

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { FileUpload } from "@/components/xzero/file-upload/file-upload";

export function Attachments() {
  return (
    <FileUpload
      accept="image/*,.pdf"
      maxSize={10 * 1024 * 1024}
      onUpload={async (file, { onProgress, signal }) => {
        await uploadWithProgress(file, onProgress, signal);
      }}
    />
  );
}

API reference

FileUpload

A dropzone with a file list that validates type and size, runs your upload per file with progress, and supports retry and remove.

PropTypeDefaultDescription
acceptstring–Comma-separated extensions or MIME types, including wildcards like image/*. Rejected files stay listed with an error.
maxSizenumber–Maximum size in bytes. Larger files are listed with an error.
multiplebooleantrueAllows several files. When false a new file replaces the old one.
disabledbooleanfalseDisables the dropzone and input.
labelstring"Upload files"Dropzone heading.
descriptionstring"Drop files here or browse from your device."Helper text, linked with aria-describedby.
valueFileUploadItem[]–Controlled file list.
onChange(files: FileUploadItem[]) => void–Called when files are added or removed.
onUpload(file: File, options: { onProgress: (percent: number) => void; signal: AbortSignal }) => Promise<void>–Uploads each valid file. Report 0-100 through onProgress, resolve when done, reject to mark it failed. Removing a file aborts its signal.

FileUploadItem

Item type: { id: string; file: File; error?: string }.

No props.

Keyboard interactions

KeysAction
Enter / SpaceOpens the file picker from the dropzone.
TabMoves through the dropzone and each row's retry and remove buttons.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components