XiodUI
HomeDocs
OverviewComponentsStyling & CustomizationChangelog

Components

  • Accordion
  • Agent Steps
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • Button Split
  • Calendar
  • Card
  • Carousel
  • Checkbox
  • Circular Progress
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy To Clipboard
  • Corner Badge
  • Dashboard Grid
  • Date Picker
  • Dialog
  • Dot Matrix
  • Draggable
    Updated
  • Drawer
  • Empty
  • Field
  • Fieldset
  • File Upload
    Updated
  • Form
  • Frame
  • Gauge
  • Grid
  • Group
  • Input
  • Input Group
  • Input OTP
  • Input Payment
  • Input Phone
    Updated
  • Input Sensitive
  • Kbd
  • Kinetic Click
  • Label
  • List Box
    Updated
  • Loader
  • Marker
  • Menu
  • Menubar
  • Message
  • Meter
  • Morphic Toast
  • Navigation Menu
  • Number Field
  • Option Picker
  • Orb
  • Pagination
  • Popover
  • Preview Card
    Updated
  • Progress
  • Radio
  • Resizable
  • Ruler Picker
  • Scroll Area
  • Scroll Bar
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Sortable
  • Switch
  • Table
  • Tabs
  • Text
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
  • Waveform
  • Wheel Picker

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

File Upload

Previous: FieldsetNext: Form

A drop zone and file picker with type and size limits, progress and a file list.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  FileUpload,3  FileUploadTrigger,4  FileUploadInput,5  FileUploadList,6  FileUploadItem,7  FileUploadItemIcon,8  FileUploadItemName,9  FileUploadItemSize,10  FileUploadItemProgress,11  FileUploadItemStatus,12  FileUploadItemRemove,13  Attachment,14  AttachmentMedia,15  AttachmentContent,16  AttachmentTitle,17  AttachmentDescription,18  AttachmentActions,19  AttachmentAction,20  AttachmentTrigger,21  AttachmentGroup22} from "xiod-ui/file-upload";

Anatomy

1<FileUpload>2  <FileUploadTrigger>3    <FileUploadInput />4  </FileUploadTrigger>5  <AttachmentGroup>6    <Attachment>7      <AttachmentMedia />8      <AttachmentContent>9        <AttachmentTitle />10        <AttachmentDescription />11      </AttachmentContent>12      <AttachmentActions>13        <AttachmentAction />14      </AttachmentActions>15    </Attachment>16  </AttachmentGroup>17</FileUpload>

API Reference

Detailed documentation of properties and options.

FileUpload

Accepts every native <div> attribute.

PropTypeDefaultDescription
accept
string
–

The file types allowed, in the format of an input's accept: MIME types, wildcards such as image/*, or extensions such as .pdf, separated by commas. Other files are added with an error.

children
FieldsetForm
ReactNode
–

The content of the component.

disabled
boolean
false

Whether the component should ignore user interaction.

files
FileItem[]
–

The files in the list. Use with onFilesChange to control them, for example to update each file's progress and status while it uploads.

labels
Partial<FileUploadLabels>
–

Replaces the built-in text — errors, statuses and announcements — for this instance. See LabelsProvider to change it everywhere.

maxFiles
number
5

The most files the list can hold. Files past the limit are left out and passed to onFilesRejected.

maxSizeMB
number
10

The largest file size allowed, in megabytes. Larger files are added with an error.

minSizeMB
number
–

The smallest file size allowed, in megabytes. Smaller files are added with an error.

onFileRemove
((id: string) => void)
–

Called with a file's id when it is removed from the list.

onFilesAdded
((files: File[]) => void)
–

Called with the files the user just picked or dropped, including ones marked with an error for their size or type. Start uploads from here.

onFilesChange
((files: FileItem[]) => void)
–

Called with the new list whenever files are added or removed.

onFilesRejected
((files: File[]) => void)
–

Called with the files left out because the list already holds maxFiles.

preventDuplicates
boolean
false

Whether a file already in the list (same name, size and last-modified time) is added with an error instead of a second time.

validate
((file: File, files: FileItem[]) => string | null)
–

Checks each new file after the size and type checks. Return a message to add the file with that error, or nothing to accept it.

FileUploadTrigger

Accepts render, plus every native <div> attribute.

FileUploadInput

Accepts every native <input> attribute.

FileUploadList

Accepts render, plus every native <div> attribute.

FileUploadItem

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
fileItemReq
FileItem
–

The file this item shows, from the FileUpload's list.

FileUploadItemIcon

Accepts render, plus every native <div> attribute.

FileUploadItemName

Accepts render, plus every native <p> attribute.

FileUploadItemSize

Accepts render, plus every native <span> attribute.

FileUploadItemProgress

Accepts render, plus every native <div> attribute.

FileUploadItemStatus

Accepts render, plus every native <div> attribute.

FileUploadItemRemove

Accepts render, plus every native <button> attribute.

PropTypeDefaultDescription
icon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

Attachment

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
orientation
"horizontal"|"vertical"
horizontal

Whether the items are laid out horizontally or vertically.

size
"sm"|"default"|"xs"
default

The size of the component.

state
"done"|"error"|"idle"|"uploading"|"processing"
done

The attachment's status, which sets its look: idle has a dashed border, uploading and processing pulse, and error turns it red.

AttachmentMedia

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
variant
"image"|"icon"
icon

The visual style of the component.

AttachmentContent

Accepts render, plus every native <div> attribute.

AttachmentTitle

Accepts render, plus every native <span> attribute.

AttachmentDescription

Accepts render, plus every native <span> attribute.

AttachmentActions

Accepts render, plus every native <div> attribute.

AttachmentAction

Accepts render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
size
"lg"|"sm"|"default"|"xl"|"xs"|"icon"|"icon-lg"|"icon-sm"|"icon-xl"|"icon-xs"
icon-xs

The size of the component.

variant
"link"|"default"|"destructive"|"outline"|"secondary"|"destructive-outline"|"ghost"
icon

The visual style of the component.

AttachmentTrigger

Accepts render, plus every native <button> attribute.

AttachmentGroup

Accepts render, plus every native <div> attribute.