File Upload

FileUpload presents a dropzone or button with a hidden file input.

Click or drop files to upload
tsx
import { FileUpload } from '@/components/ui/wideset/file-upload/FileUpload';

<FileUpload onBrowse={open} />

Installation

pnpm dlx wideset add file-upload

Copies the component and any Wideset components it uses into your project.

Examples

Types

The plain dropzone is itself the control: it takes focus and opens the picker on click, Enter or Space. With browse, the Browse button takes that job and the zone only receives drops; pick it when the zone sits among other controls and a click on the empty area should do nothing. The button trigger has no drop area, for tight spaces like a toolbar or a table row. onBrowse is your file library's open().

tsx
import { FileUpload } from '@/components/ui/wideset/file-upload/FileUpload';

const open = () => {};

export default function FileUploadTypes() {
  return (
    <div className="gap-ws-12 flex w-[26rem] max-w-full flex-col">
      <FileUpload onBrowse={open} />
      <FileUpload browse onBrowse={open} />
      <FileUpload type="button" onBrowse={open} />
    </div>
  );
}

States

isDragActive comes from your file library while a file is held over the zone; the label changes to say "Drop files here" and the Browse button steps aside. Disabled takes the zone out of the tab order and makes it ignore the pointer, drops included; the hidden file input is disabled as well.

tsx
import { FileUpload } from '@/components/ui/wideset/file-upload/FileUpload';

const open = () => {};

export default function FileUploadStates() {
  return (
    <div className="gap-x-ws-7 gap-y-ws-9 grid w-[34rem] max-w-full grid-cols-[4rem_minmax(0,1fr)] items-center">
      <span className="typography-caption-md text-ws-static-subtle">Default</span>
      <FileUpload className="min-w-0" browse onBrowse={open} />
      <span className="typography-caption-md text-ws-static-subtle">Drag over</span>
      <FileUpload className="min-w-0" browse isDragActive onBrowse={open} />
      <span className="typography-caption-md text-ws-static-subtle">Disabled</span>
      <FileUpload className="min-w-0" browse disabled onBrowse={open} />
    </div>
  );
}

API reference

FileUpload

NameDescriptionDefault
onBrowse*

Opens the file picker — a file-handling library's `open()`.

() => void
—
browse

Dropzone only: renders the Browse button inside the zone — Figma's `Type=Button`.

boolean
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the trigger and the Browse button.

boolean
false
inputProps

Renders a hidden `<input type="file">` with these props — a file-handling library's input props. `type="file"`, `sr-only` and `tabIndex={-1}` are the defaults; anything given here wins.

InputHTMLAttributes<HTMLInputElement>
—
isDragActive

Dropzone only: marks the zone as receiving a drag.

boolean
—
labels

Override default text labels for the dropzone, active dropzone, browse button, and upload button.

FileUploadLabels
—
type

The dropzone (default) or the compact button trigger — Figma's `File Upload` `Type`.

'button''dropzone'
'dropzone'
zoneProps

Dropzone only: spread onto the zone — a library's root props, drag props only.

HTMLAttributes<HTMLElement>
—
Every other prop of <div> is passed through to it. See MDN: <div>.

FileUpload.Dropzone

NameDescriptionDefault
onBrowse*

Opens the file picker — a file-handling library's `open()`. Called from the Browse button, or from the zone itself on `Type=Area`.

() => void
—
browse

Renders the Browse button — Figma's `Type=Button`. Without it the zone itself is the control (`Type=Area`).

boolean
false
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the trigger and the Browse button.

boolean
false
isDragActive

Marks the dropzone as actively receiving a drag — typically from react-dropzone.

boolean
false
labels

Override default text labels for the dropzone, active dropzone, browse button, and upload button.

Pick<FileUploadLabels, 'dropzone' | 'dropzoneActive' | 'dropzoneBrowse' | 'browse'>
—
zoneProps

Spread onto the zone — a file-handling library's root props, for drag and drop. Only the drag props are kept: `onClick`, `onKeyDown`, `onKeyUp`, `tabIndex` and `role` are dropped, since activation is the component's and ends in `onBrowse`.

HTMLAttributes<HTMLElement>
—
Every other prop of <element> is passed through to it. See MDN: global attributes.

FileUpload.Trigger

NameDescriptionDefault
onBrowse*

Opens the file picker — a file-handling library’s `open()`. Called from the Browse button, from the `Type=Area` zone, or from the button trigger.

() => void
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the trigger and the Browse button.

boolean
false
label

Visible label for the control.

ReactNode
—

Accessibility

  • The plain dropzone has the button role and is named by its label text; with browse, the Browse button is the control.
  • The hidden file input is out of the tab order on purpose; do not give it focus.
  • Announce rejected files and finished uploads yourself; rows appearing are not announced.
PartRendersDescription
FileUpload<div>A file browsing trigger or dropzone connected to an upload handler.
FileUpload.Dropzone<element>The drop area: with `browse` it carries a Browse button, otherwise the whole zone is the control.
FileUpload.Trigger—The control that opens or toggles the associated content.
Click or drop files to upload
tsx
import { FileUpload } from '@/components/ui/wideset/file-upload/FileUpload';

<FileUpload onBrowse={open} />

Appearance

Type
Browse button

Content

File list

State

Disabled
Drag over