Menu

File upload

Drag & drop zone. 4 states.

Installation

$ npx uix-ui@latest add file-upload

This copies the file into components/ui/file-upload.tsx in your project. npx shadcn@latest add @uix/file-upload works too.

Usage

file-upload.tsx
import { FileUpload } from "@/components/ui/file-upload";

<div style={{ width: 360, maxWidth: "100%" }}>
  <FileUpload onFiles={files => setName(files[0]?.name ?? "")} helper={name ? `Added: ${name}` : "PNG or SVG, up to 2 MB."} />
</div>

Props

PropTypeDefaultDescription
onFiles(files: File[]) => void–Called with the chosen or dropped files.
helperReact.ReactNode–Text under the prompt, for example the accepted types.
errorstring–Error message; replaces the helper text and turns the zone red.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close