File Upload
File upload with drag and drop
UI PrimitiveForm Inputs
Overview
A compound component that manages file state internally. Provides a dropzone area and a file list sub-component. Validates file type and size before adding files.
Usage
import { FileUpload } from "@leanicon/web-builder-library";
<FileUpload
accept="image/*,.pdf"
maxSize={5 * 1024 * 1024}
multiple
onFilesChange={(files) => console.log(files)}
>
<FileUpload.Dropzone />
<FileUpload.FileList />
</FileUpload>;Drop files here or click to browse
Notes
- Error messages are displayed automatically below the dropzone when validation fails.
FileUpload.Dropzonesupports click, keyboard (Enter/Space), and drag-and-drop interaction.FileUpload.FileListrenders nothing when no files are selected.- The hidden
<input type="file">is managed internally; useonFilesChangeto access selected files. - Dark mode is handled via semantic tokens.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
accept | string | — | No | |
maxSize | number | — | No | |
multiple | boolean | false | No | |
onFilesChange | ((files: File[]) => void) | — | No | |
disabled | boolean | false | No | |
className | string | — | No |