formsfile-upload
FileUpload
Drag-and-drop file upload component with progress tracking and file list management.
Import#
Slot Structure#
Upload control and optional file preview list.
Upload area#
File preview list#
Examples#
Single Upload#
Basic single-file mode with a live readout from onValueChange.
Multiple + Max Files#
Append files across selections, reject overflow, and show selected names.
Sizes#
Size scale from xs to xl for trigger height, spacing, and file list density.
Trigger Mode (No Dropzone)#
Use button-style trigger behavior by disabling dropzone interaction.
Form Integration#
Submit to validate a required attachment with Form + FormField.
API Reference#
Attributes#
Slot
root3 attributesUpload component container that owns dropzone, file input, and file list.
Data Attributes
| Data Attribute | Description |
|---|---|
| data-disabled | Present when the component or item is disabled. |
| data-readonly | Present when the field is read-only. |
ARIA Attributes
| ARIA Attribute | Description |
|---|---|
| role | Defines the semantic role exposed to assistive technology. |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| accept | string | undefined | * | Accepted file types (e.g., ".jpg,.png", "image/*"). |
| as | "div" | undefined | div | The HTML element or component to render as. |
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | FileUploadT.Classes | undefined | — | — |
| description | JSX.Element | — | Description text for the upload area. |
| disabled | boolean | undefined | false | Whether the input is disabled. |
| dropzone | boolean | undefined | true | Whether to enable drag and drop. |
| fileIcon | IconT.Name | icon-file | Icon to show for individual files when no preview is available. |
| icon | IconT.Name | icon-upload | Icon to show in the upload area. |
| id | string | undefined | — | The ID of the input element. |
| label | JSX.Element | — | Label for the upload area. |
| maxFiles | number | undefined | — | Maximum number of files allowed. |
| maxSize | number | undefined | — | Maximum accepted file size in bytes. |
| minSize | number | undefined | — | Minimum accepted file size in bytes. |
| multiple | boolean | undefined | false | Whether multiple files can be uploaded. |
| name | string | undefined | — | The name of the input element, used for form submission. |
| onClick | JSX.EventHandlerUnion<HTMLElement, MouseEvent> | undefined | — | Click handler for the upload control. |
| onDragLeave | JSX.EventHandlerUnion<HTMLElement, DragEvent> | undefined | — | Drag-leave handler for the upload dropzone. |
| onDragOver | JSX.EventHandlerUnion<HTMLElement, DragEvent> | undefined | — | Drag-over handler for the upload dropzone. |
| onDrop | JSX.EventHandlerUnion<HTMLElement, DragEvent> | undefined | — | Drop handler for the upload dropzone. |
| onFileReject | ((files: FileRejection[]) => void) | undefined | — | Callback when files are rejected (e.g., due to type or count). |
| onKeyDown | JSX.EventHandlerUnion<HTMLElement, KeyboardEvent> | undefined | — | Keyboard handler for the upload control. |
| onValueChange | ((value: FileUploadT.Value) => void) | undefined | — | Callback when the selected files change. |
| preview | boolean | undefined | true | Whether to show file previews. |
| readOnly | boolean | undefined | false | Whether the input is read-only. |
| ref | JSX.HTMLElementTags["div"] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| required | boolean | undefined | false | Whether the input is required. |
| size | "xs" | "sm" | "md" | "lg" | "xl" | undefined | — | — |
| style | JSX.CSSProperties | undefined | — | — |
| styles | FileUploadT.Styles | undefined | — | — |