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 |
---|
accept File types to accept for upload. An array of strings of the MIME type and/or file extensions to accept.
|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
disabled Whether the file uploader is disabled.
|
onFilesDrop Callback function called when files are dropped or selected
|
#
FileUploadDropzone
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
description Add secondary text after the primary label.
|
label The label of the dropzone.
Default: |
overlay Whether 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 |
---|
addonAfter Display content inside the button after
|
addonBefore Display content inside the button before
|
appearance Control the appearance by selecting between the different button types.
|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
disabled Whether the button is disabled.
|
icon Display an icon before or after the button content or omit
|
iconPosition Control whether to show the icon before or after the button content.
|
loading Whether to show loading spinner inside the button.
|
size Control the size of the button.
|
square Whether button should have square shape.
|
#
Changelog
#
#
1.6.0
#
- Added component