Design System
Forms

File upload

A drop target and file list for attaching documents such as receipts, referral letters and claim evidence.

Purpose

Two parts: FileUpload is the dashed drop target (click to browse, or drag and drop), and FileUploadItem rows carry each attached file through its lifecycle — uploading, complete, error. The pair is transport-agnostic: wire onFilesSelected to your upload client and drive each row's status/progress from it. The progress bar inside a row is the Progress component; for typed references rather than attachments (a claim number, a URL) use an Input.

Example

Pick or drop a file — it lands in the list below the target:

Wiring to an upload client
import { FileUpload, FileUploadItem } from "@healthmetrics/ui/file-upload";

<FileUpload
  hint="PDF or JPG, up to 10 MB each"
  accept=".pdf,.jpg,.jpeg"
  onFilesSelected={(files) => files.forEach(startUpload)}
/>

{uploads.map((u) => (
  <FileUploadItem
    key={u.id}
    name={u.name}
    size={u.size}
    status={u.status}       // "uploading" | "complete" | "error"
    progress={u.progress}   // 0–100 while uploading
    errorMessage={u.error}
    onRetry={() => retry(u.id)}
    onRemove={() => remove(u.id)}
  />
))}

multiple defaults on; every other native file-input attribute (accept, capture, name…) passes through to the hidden input.

States

The drop target has default, drag-over, error and disabled states; drag-over turns the border --primary with an --accent fill as the file crosses it.

Only PDF and JPG files are accepted.

Item rows carry the per-file lifecycle. uploading shows the progress bar with a percentage, complete a success check, and error the message with a Retry action when onRetry is passed; the Remove button appears whenever onRemove is passed:

referral-letter.jpg

3.8 MB
45%

receipt-klinik-mediviron.pdf

1.2 MB

mc-scan.pdf

12.4 MB

File exceeds the 10 MB limit.

Structure

PropertyValue
Drop target2px dashed --input, --radius-xl, 24px/32px padding
Drag-overborder --primary, --accent fill
Target errorborder --destructive; 12px --destructive-text message below
Icon tile40px square, --accent fill, 22px upload_file glyph
Focus2px --ring with 2px offset (focus-within, the input is the tab stop)
Disabled50% opacity, not-allowed cursor
Item row1px border, --card fill, --radius-lg, 12px padding
Row icon tile36px square; draft glyph, or error on --destructive-subtle
Progress6px bar (h-1.5) + tabular percentage
Success mark20px check_circle glyph, --success-text

Best practices

Do

  • State the accepted formats and size limit in hint — and enforce them with accept plus your own size check in onFilesSelected.
  • Keep every selected file visible as a FileUploadItem row — silence after a drop reads as a failed upload.
  • Pass onRetry on error rows — re-dragging the same file is the frustrating alternative.
  • Put row-level failures on the row (errorMessage) and target-level failures on the target (error) — a rejected file type is the target's problem; a failed transfer is the row's.

Don't

  • Rely on drag and drop alone — the click-to-browse path is the one that works everywhere, including for keyboard and screen-reader users.
  • Fake progress with an animation — show real transfer progress or none.
  • Remove a failed row automatically — the user needs to see what failed and why.

Accessibility & keyboard

  • The drop target is a <label> wrapping the real (visually hidden) file input — clicking anywhere opens the picker, and the label text ("Click to upload or drag and drop" plus the hint) is the input's accessible name. No nested-interactive tricks.
  • The hidden input is the tab stop; focus draws the 2px ring on the whole target via focus-within.
  • Drag and drop is an enhancement only — browse is the equivalent path, so no keyboard drop handling is needed.
  • The target's error sets aria-invalid on the input and is linked via aria-describedby (id {id}-error); the message is a polite live region, so it is announced when it appears.
  • On rows, the progress bar is labelled "Uploading name" and the remove button "Remove name"; Retry is a plain labelled button.
  • Keyboard: Tab to the target; Enter or Space opens the file picker; on rows, Tab reaches Retry and Remove.

Props

PropTypeDefaultDescription
onFilesSelected((files: File[]) => void) | undefined—Called with the chosen files (from browse or drop).
errorstring | undefined—Error message rendered under the drop target (Figma "Error" state).
hintstring | undefined—Helper line, e.g. accepted formats and size limit.
classNamestring | undefined——

FileUploadItem renders one attached file:

PropTypeDefaultDescription
namerequiredstring—File name shown on the row.
sizestring | undefined—Human-readable size, e.g. "2.4 MB".
status"uploading" | "complete" | "error" | undefined"complete"Row status (Figma variants): `uploading` shows the progress bar, `complete` a success check, `error` the message + retry.
progressnumber | undefined—Upload progress 0–100 (uploading only).
errorMessagestring | undefined—Error message (error only).
onRetry(() => void) | undefined——
onRemove(() => void) | undefined——

On this page