Components
File Upload
Manages file upload states including drag-and-drop, loading, error, and image preview. Built with the compound component pattern for flexible composition.
Replacing soon
GitHubDrag and drop files here to upload
Anatomy
Anatomy
import {FileUpload} from '@staffbase/spark';
<FileUpload>
<FileUpload.Wrapper />
<FileUpload.Text />
<FileUpload.Preview />
<FileUpload.Overlay />
</FileUpload>;Examples
Loading state
Error state
Upload failed
Please try again
Image preview
Opening the file chooser programmatically
Drag and drop files here to upload or
API reference
FileUpload
| Name | Type | Description |
|---|---|---|
onDrop | DropzoneOptions['onDrop'] | Called with the accepted files when they are dropped onto the dropzone. |
variant | defaultloadingdraggingerrorhasImage | Controls the visual border style of the component. |
children | ReactNode | Content to display inside the dropzone. Use `FileUpload.Wrapper` to differentiate drag and non-drag states. |
disabled | boolean | Disables the dropzone. |
accept | DropzoneOptions['accept'] | Restricts accepted file types, e.g. `{'image/png': ['.png']}`. |
ref | MutableRefObject<FileUploadRef> | Ref exposing `openFileChooser()` to programmatically open the native file picker. |
className | string | CSS class applied to the root element. |
Wrapper
| Name | Type | Description |
|---|---|---|
showOnDrag | boolean | When `true`, renders children only while a drag is active. When `false`, renders children at all other times. |
children | ReactNode | Content to show in the relevant drag state. |
Text
| Name | Type | Description |
|---|---|---|
children | string | The text content. |
variant | defaultcriticalinfoneutral | Visual style of the text. Default: default |
Preview
| Name | Type | Description |
|---|---|---|
previewUrl | string | URL of the image to display as the preview background. |
onEdit | () => void | When provided, renders an edit icon button that calls this handler. |
onDelete | () => void | When provided, renders a delete icon button that calls this handler. |
additionalButtons | ReactElement | Additional action buttons rendered alongside edit and delete. |
children | ReactNode | Overlay content, such as `FileUpload.Overlay`. |
Overlay
| Name | Type | Description |
|---|---|---|
children | ReactNode | Content displayed inside the overlay. |