Skip to content

File Upload

A drag-and-drop zone or button for selecting files. Shows file name, type hint, and validation states.

Preview

Drop files here or click to browsePNG, JPG, PDF up to 10 MB

With file selected

Drop files here or click to browsePNG, JPG, PDF up to 10 MB
screenshot.png (2.4 MB)

Error state

Drop files here or click to browsePNG, JPG, PDF up to 10 MB
File exceeds the 10 MB size limit.

Disabled

Upload disabled

States

StateAppearance
EmptyDashed border, upload icon, instruction text
Hover / Drag-overBrand-purple border, subtle purple background tint
File selectedFile name displayed below instructions
ErrorRed dashed border with error message
DisabledReduced opacity, no interaction

Props

PropTypeDefaultDescription
acceptstring--Accepted file types (e.g. '.png,.jpg,.pdf')
maxSizenumber--Maximum file size in bytes
multiplebooleanfalseAllow multiple files
onChange(files: File[]) => void--File selection handler
errorstring--Error message
disabledbooleanfalseDisables the upload zone
hintstring--File type/size hint text

Code example

React

tsx
import { FileUpload } from '@thepace/lexicon/components';

<FileUpload
  accept=".png,.jpg,.pdf"
  maxSize={10 * 1024 * 1024}
  hint="PNG, JPG, PDF up to 10 MB"
  onChange={handleFiles}
/>

Vanilla HTML

html
<div class="lex-file-upload" tabindex="0" role="button">
  <span class="lex-file-upload__icon"><!-- upload SVG --></span>
  <span class="lex-file-upload__text">Drop files here or click to browse</span>
  <span class="lex-file-upload__hint">PNG, JPG, PDF up to 10 MB</span>
  <input type="file" accept=".png,.jpg,.pdf" hidden />
</div>

CSS class reference

ClassPurpose
.lex-file-uploadDrop zone container
.lex-file-upload--dragoverActive drag-over state
.lex-file-upload--errorError state
.lex-file-upload--disabledDisabled state
.lex-file-upload__iconUpload icon
.lex-file-upload__textPrimary instruction text
.lex-file-upload__hintFile type/size hint
.lex-file-upload__fileSelected file display

Accessibility

  • role="button" and tabindex="0" make the drop zone keyboard-accessible.
  • Hidden <input type="file"> is triggered on click/Enter/Space.
  • Announce file selections with aria-live="polite".
  • Error messages linked via aria-describedby.

Guidelines

Do

  • Display accepted file types and size limits clearly.
  • Show selected file names with an option to remove.

Don't

  • Don't auto-upload on selection without user confirmation.
  • Don't allow arbitrarily large files without server-side validation.

Released under the MIT License. A product by the pace.