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.
file-input-demo.tsxCopy code
Installation
Copy code
npm packages
lucide-reactUsage
ImportCopy code
Reach for it to attach or upload files; FileUpload is the drop zone, the list and the errors in one.
API reference
FileInput
FileInputTrigger
| Prop | Type | Default |
|---|---|---|
variant | "default" | "secondary" | "outline" | "ghost" | "outline" |
size | "sm" | "default" | "lg" | "sm" |
Also takes every prop of UI SDK FileInputTrigger.
FileInputDropzone
FileInputList
FileInputItem
FileInputItemRemove
| Prop | Type | Default |
|---|---|---|
tooltip | ControlTooltipOption | – |
Also takes every prop of UI SDK FileInputItemRemove.
FileInputFiles
| Prop | Type | Default |
|---|---|---|
labels | Partial<FileInputLabels> | – |
locale | string | – |
Also takes every prop of UI SDK FileInputList except children.
FileInputRejections
| Prop | Type | Default |
|---|---|---|
rejectionsrequired | readonly FileRejection[] | – |
limits | FileLimits | noLimits |
labels | Partial<FileInputLabels> | – |
locale | string | – |
Also takes <ul> attributes.
FileUpload
| Prop | Type | Default |
|---|---|---|
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 | – |
labels | Partial<FileInputLabels> | – |
locale | string | – |
Also takes every prop of UI SDK FileInput except children.
Other exports
fileInputLabelscreateFileInputControllerformatFileSizerelativePathtype FileInputFilesPropstype FileInputLabelstype FileInputRejectionsPropstype FileInputTriggerPropstype FileLimitstype FileUploadPropstype FileInputControllertype FileInputValueChangeDetailstype FileInputValueChangeReasontype FileRejectiontype FileRejectionReasonAccessibility
- 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.