Skip to content
SENVENLI UI

File upload

Pick files with a button or by dropping them, validate size and type, and show each file with its progress or error.
Drop zone with a list
import {
  FileTrigger,
  DropZone,
  FileUploadList,
  FileRow,
} from "@senvenli/react/form";

Examples

From a button

FileTrigger opens the system picker from any Button.

Row states

Uploaded, uploading with progress, and failed.

Guidelines

When to use it

  • People add documents or photos to a form or record.

Use something else when

  • One picture must be framed to a fixed shape before it is saved. Image cropper
  • A link or path to the file is typed instead of picked. Input

Accessibility

Keyboard

KeysWhat happens
Enter, SpaceOpens the file picker from the trigger or drop zone.

Built in

  • Rejected files explain why (size, type, count).
  • Upload progress is exposed as a progress bar.

You provide

  • A label that says what to add.

API reference

FileTrigger

acceptedFileTypes
readonly string[]

MIME types or extensions: "image/jpeg", "image/*", ".heic", "application/pdf".

maxSize
number

Bytes.

onSelect
(files: File[]) => void

Files that passed the rules.

onReject
(rejected: RejectedFile[]) => void

Files that did not, each with its reason.

Also takes 70 standard DOM and ARIA attributes (id, aria-label, event handlers…).

DropZone

acceptedFileTypes
readonly string[]

MIME types or extensions: "image/jpeg", "image/*", ".heic", "application/pdf".

maxSize
number

Bytes.

labelRequired
string

What to drop, as a call to action: "Drag your photos here".

typesLabel
string

The accepted types as people read them ("JPG, PNG, HEIC"); the size limit is added.

allowsMultiple
boolean
onSelect
(files: File[]) => void
onReject
(rejected: RejectedFile[]) => void
isDisabled
boolean

FileUploadList

childrenRequired
React.ReactNode
aria-label
string

FileRow

file
File

The picked file; photos get a thumbnail at once, before upload ends.

name
string

Shown name and size when there is no File object (a stored document).

size
number
progress
number

0–1 while uploading; omit when done.

error
string
onCancel
() => void
onRemove
() => void
onReplace
() => void