Skip to content
Eskais UI

Forms

File Input

UI SDK FileInput styled as a drop zone with a browse button: accept, size and count limits, the chosen files as attachment chips with remove buttons, and why any were left out in the destructive tone.

Example

Drop files hereImages or PDF, up to 5 MB each

Up to four files.

Installation

npx shadcn@latest add @eskais/file-input
npm packageslucide-react

Usage

Import
import {  FileInput,  FileInputDropzone,  FileInputFiles,  FileInputItem,  FileInputItemRemove,  FileInputList,  FileInputRejections,  FileInputTrigger,  FileUpload,  fileInputLabels,  createFileInputController,  formatFileSize,  relativePath,} from "@/components/ui/file-input"

Reach for it to attach or upload files; FileUpload is the drop zone, the list and the errors in one.

API reference

FileInputTrigger

PropTypeDefault
variant"default" | "secondary" | "outline" | "ghost""outline"
size"sm" | "default" | "lg""sm"

Also takes every prop of UI SDK FileInputTrigger.

FileInputItemRemove

PropTypeDefault
tooltipControlTooltipOption–

Also takes every prop of UI SDK FileInputItemRemove.

FileInputFiles

PropTypeDefault
labelsPartial<FileInputLabels>–
localestring–

Also takes every prop of UI SDK FileInputList except children.

FileInputRejections

PropTypeDefault
rejectionsrequiredreadonly FileRejection[]–
limitsFileLimitsnoLimits
labelsPartial<FileInputLabels>–
localestring–

Also takes <ul> attributes.

FileUpload

PropTypeDefault
titlerequiredThe drop zone's prompt, like "Drop files here".ReactNode–
descriptionWhat it takes, like "PNG or PDF, up to 5 MB".ReactNode–
browseLabelrequiredThe trigger's text, like "Browse files".ReactNode–
labelsPartial<FileInputLabels>–
localestring–

Also takes every prop of UI SDK FileInput except children.

Other exports

fileInputLabelscreateFileInputControllerformatFileSizerelativePathtype FileInputFilesPropstype FileInputLabelstype FileInputRejectionsPropstype FileInputTriggerPropstype FileLimitstype FileUploadPropstype FileInputControllertype FileInputValueChangeDetailstype FileInputValueChangeReasontype FileRejectiontype FileRejectionReason

Accessibility

  • The browse button is the field's control, so the Field's label names it and Enter or Space opens the picker; dropping is never the only way.
  • The file list has one tab stop: arrows move between files and Delete removes one; remove buttons are named for their file.
  • Added, removed and rejected files are announced in a polite live region; the reasons also show in the destructive tone.

Agent actions

Agents find it by its label and can clear it or remove a file; picking files stays with a person.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.