FileUpload
Capture file input from users with drag and drop.
This component is only for capturing file input from users and does not handle actual uploading of files or making HTTP requests.
#
Documentation
#
#
Usage
#
Drag and drop files here
SVG, PNG, JPG or GIF (max. 2MB)
"use client";
import { toaster } from "@optiaxiom/react";
import { FileUpload, FileUploadDropzone } from "@optiaxiom/react/unstable";
export function App() {
return (
<FileUpload
accept={["image/*"]}
onFilesDrop={(files) => {
toaster.create(`${files.length} files added!`);
}}
w="384"
>
<FileUploadDropzone description="SVG, PNG, JPG or GIF (max. 2MB)" />
</FileUpload>
);
}#
Props
#
#
FileUpload
#
Supports all Box props in addition to its own. Renders a <div> element.
Prop |
|---|
acceptFile types to accept for upload. An array of strings of the MIME type and/or file extensions to accept.
|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
disabledWhether the file uploader is disabled.
|
onFilesDropCallback function called when files are dropped or selected
|
#
FileUploadDropzone
#
Supports all Box props in addition to its own. Renders a <div> element.
Prop |
|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
descriptionAdd secondary text after the primary label.
|
labelThe label of the dropzone.
Default: |
overlayWhether to place the dropzone as an overlay fully covering the parent container and only visible when user is dragging a file into the browser.
Default: |
#
FileUploadTrigger
#
Supports all Button props in addition to its own. Renders a <button> element.
Prop |
|---|
addonAfterDisplay content inside the button after
|
addonBeforeDisplay content inside the button before
|
appearanceControl the appearance by selecting between the different button types.
|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
disabledWhether the button is disabled.
|
iconDisplay an icon before or after the button content or omit
|
iconPositionControl whether to show the icon before or after the button content.
|
loadingWhether to show loading spinner inside the button.
|
sizeControl the size of the button.
|
squareWhether button should have square shape.
|
#
Changelog
#
#
1.6.0
#
- Added component