Upload
Drag-and-drop file picker with previews and validation.
Installation
bun add @xerobi/ui
import { DeleteButton, MultiFilePreview, RejectionFiles, SingleFilePreview, Upload, UploadAvatar, UploadBox, UploadPlaceholder } from "@xerobi/ui/upload"This component is client-side. In Astro, hydrate it with a client directive.
API reference
DeleteButton
Also accepts every prop of <button> element.
No props of its own.
MultiFilePreview
| Prop | Type | Description |
|---|---|---|
| files* | (string | File)[] | |
| lastNode | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| firstNode | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| onRemove | (file: string | File) => void | |
| thumbnail | boolean | |
| slotProps | { thumbnail?: Omit<FileThumbnailProps, "file"> | undefined; } |
RejectionFiles
| Prop | Type | Description |
|---|---|---|
| files | readonly FileRejection[] |
SingleFilePreview
| Prop | Type | Description |
|---|---|---|
| file* | string | File |
Upload
| Prop | Type | Description |
|---|---|---|
| error | boolean | |
| className | string | |
| thumbnail | boolean | |
| helperText | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| placeholder | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| value | string | File | FilesUploadType | |
| onDelete | () => void | |
| onUpload | () => void | |
| onRemoveAll | () => void | |
| onRemove | (file: string | File) => void | |
| labels | { removeAll?: string | undefined; upload?: string | undefined; updatePhoto?: string | undefined; uploadPhoto?: string | undefined; } |
UploadAvatar
| Prop | Type | Description |
|---|---|---|
| error | boolean | |
| className | string | |
| thumbnail | boolean | |
| helperText | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| placeholder | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| value | string | File | FilesUploadType | |
| onDelete | () => void | |
| onUpload | () => void | |
| onRemoveAll | () => void | |
| onRemove | (file: string | File) => void | |
| labels | { removeAll?: string | undefined; upload?: string | undefined; updatePhoto?: string | undefined; uploadPhoto?: string | undefined; } |
UploadBox
| Prop | Type | Description |
|---|---|---|
| error | boolean | |
| className | string | |
| thumbnail | boolean | |
| helperText | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| placeholder | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| value | string | File | FilesUploadType | |
| onDelete | () => void | |
| onUpload | () => void | |
| onRemoveAll | () => void | |
| onRemove | (file: string | File) => void | |
| labels | { removeAll?: string | undefined; upload?: string | undefined; updatePhoto?: string | undefined; uploadPhoto?: string | undefined; } |
UploadPlaceholder
| Prop | Type | Description |
|---|---|---|
| labels | { title?: string | undefined; before?: string | undefined; link?: string | undefined; after?: string | undefined; } |