File Upload API
View componentThe full prop reference for the File Upload component. A drag-and-drop file input with validation.
Import
import { FileUpload } from '@structyl/styled';Props
Root
The main provider component that manages file state and validation; accepts all standard div HTML attributes
| Prop | Type | Default |
|---|---|---|
| asChild# | booleanReplace the root div with a child element (use Slot pattern) | — |
| value# | File[]Controlled list of currently selected files | — |
| defaultValue# | File[]Initial uncontrolled file list | [] |
| onValueChange# | (files: File[]) => voidCallback when the file list changes (add/remove) | — |
| accept# | stringComma-separated MIME types or file extensions to accept (e.g. 'image/*' or '.pdf,.doc') | — |
| multiple# | booleanAllow selecting multiple files; if false, only one file at a time | false |
| maxSize# | numberMaximum file size in bytes; files exceeding this trigger a 'size' error | — |
| maxFiles# | numberMaximum number of files allowed; files exceeding this trigger a 'count' error | — |
| disabled# | booleanDisable file selection in Dropzone, Trigger, and Input | — |
| onError# | (errors: Array<{file: File; reason: 'size' | 'type' | 'count'}>) => voidCallback for validation errors (size exceeded, type not accepted, max count exceeded) | — |
| className# | stringCSS class names for custom styling | — |
Dropzone
Drag-and-drop zone; accepts all standard div HTML attributes; features drag state data-state='dragging'|'idle' and data-disabled attribute
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class names for custom styling (styled version includes sensible defaults) | — |
| children# | React.ReactNodeCustom content; styled version defaults to Upload icon + descriptive text if omitted | — |
| onClick# | (event: React.MouseEvent<HTMLDivElement>) => voidTriggered on click; automatically opens file picker | — |
| onDragOver# | (event: React.DragEvent<HTMLDivElement>) => voidTriggered during drag; composable with internal drag state | — |
| onDragLeave# | (event: React.DragEvent<HTMLDivElement>) => voidTriggered when drag leaves; composable with internal drag state | — |
| onDrop# | (event: React.DragEvent<HTMLDivElement>) => voidTriggered on drop; composable with file addition | — |
Input
Hidden file input element (type='file'); automatically receives accept and multiple from Root context; forwards standard input HTML attributes
| Prop | Type | Default |
|---|---|---|
| onChange# | (event: React.ChangeEvent<HTMLInputElement>) => voidTriggered on file selection; composable with internal file addition logic | — |
Trigger
Button to trigger file selection; automatically opens the hidden input on click; forwards standard button HTML attributes
| Prop | Type | Default |
|---|---|---|
| onClick# | (event: React.MouseEvent<HTMLButtonElement>) => voidTriggered on click; composable with file picker opening | — |
Clear
Button to clear all selected files; automatically disabled when Root.disabled is true or no files exist; forwards standard button HTML attributes
| Prop | Type | Default |
|---|---|---|
| onClick# | (event: React.MouseEvent<HTMLButtonElement>) => voidTriggered on click; composable with internal clear logic | — |
List
Container for file items (ul element); accepts all standard ul/list HTML attributes
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class names for custom styling (styled version defaults to 'mt-2 space-y-1') | — |
Item
Individual file item (li element); displays file name and size in styled version; forwards standard li HTML attributes
| Prop | Type | Default |
|---|---|---|
| file# | FileRequired - the File object to display; used as key and for data-file-name attribute | — |
| children# | React.ReactNodeCustom content; styled version defaults to file name + size display if omitted | — |
| className# | stringCSS class names for custom styling | — |
Source code
If you didn't find what you need here, read the component implementation .