Upload

free

Upload handles file selection, drop zones, validation, and removable file lists.

Drag and Drop file here or Choose file

Supported formats: XLS, XLSXMaximum size: 25MB
XLS

Table Name.xls

3 MB

import { useState } from 'react';
import CloseButton from '@/components/ui/close-button';
import Upload from '@/components/ui/upload';
import Alert from '@/components/ui/alert';

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Upload

Examples

Basic

import Upload from '@/components/ui/upload';

export default function BasicDemo() {
  return (

Drag And Drop

Drop files here or browse

Multiple documents can be attached at once.

import Upload from '@/components/ui/upload';
import { PiCloudArrowUp } from 'react-icons/pi'

export default function DragAndDropDemo() {

Custom Trigger

import Upload from '@/components/ui/upload';
import Button from '@/components/ui/button';
import { PiUploadSimple } from 'react-icons/pi'

Validation

Supported formats: PNG, JPEG. Maximum size: 500 KB.
import { useState } from 'react';
import Upload from '@/components/ui/upload';
import Alert from '@/components/ui/alert';

Avatar Image

Profile photo

import { useEffect, useState } from 'react';
import Avatar from '@/components/ui/avatar';
import Button from '@/components/ui/button';
import Upload from '@/components/ui/upload';

Controlled

Controlled file count

2 files
PDF
Vendor-agreement.pdf
232 kb
ZIP
Invoice-export.zip
118 kb
import { useState } from 'react';
import Upload from '@/components/ui/upload';
import Tag from '@/components/ui/tag';

Custom File Item

Recording.mp3

audio/mpeg4180 KB
TXT

Release-notes.txt

text/plain21 KB
ZIP

Archive.zip

application/x-zip-compressed1620 KB
import { useState } from 'react';
import Upload from '@/components/ui/upload';
import Button from '@/components/ui/button';
import CloseButton from '@/components/ui/close-button';

Disabled

Uploading is unavailable for archived records.
import Upload from '@/components/ui/upload';

export default function DisabledDemo() {
  return (

API

Upload manages browser file selection and an in-memory list of selected files. It does not send files to a server by itself; use onChange, beforeUpload, and customFileItem to connect it to the workflow around it.

PropDescriptionTypeDefault
acceptFile accept string forwarded to the hidden file input.string-
beforeUploadSynchronously validates selected files before they are added to the list. Return false or a message string to block them.UploadBeforeUpload-
childrenCustom trigger content. Without children, Upload renders its default button or dropzone text.ReactNode-
customFileItemCustom renderer for each listed file. Receives the file, index, remove callback, and internal FileIcon renderer.UploadCustomFileItem-
disabledPrevents file selection and applies disabled styling.booleanfalse
draggableRenders a dashed drop area and enables drag-over feedback.booleanfalse
fileListControlled file list. When omitted, Upload stores selected files internally.File[]-
fileListClassClass names applied to the file-list wrapper.string-
fileItemClassClass names applied to default file rows.string-
multipleAllows selecting more than one file.boolean-
onBeforeUploadCalled when beforeUpload blocks a file, with false or the returned message.(result: boolean | string) => void-
onChangeCalled after a valid file is added. Receives the first selected file and the full list.UploadChangeHandler-
onFileRemoveCalled after a file is removed. Receives the removed file and the next list.UploadRemoveHandler-
showListShows the selected file list below the trigger.booleantrue
tipHint content rendered below the trigger.string | ReactNode-
uploadLimitLimit checked before adding another selection. When set to 1, the next valid upload replaces the current file.number-
classNameExtra classes for the root upload container.string-
refRef forwarded to the root upload container.Ref<HTMLDivElement>-
...nativePropsNative props forwarded through the root container type.UploadNativeProps-

Types

type UploadBeforeUpload = (
  files: FileList | null,
  fileList: File[],
) => boolean | string
 
type UploadChangeHandler = (file: File, fileList: File[]) => void
 
type UploadRemoveHandler = (file: File, fileList: File[]) => void
 
type UploadCustomFileItem = (props: {
  file: File
  index: number
  onRemove: () => void
  FileIcon: (props: FileIconProps) => JSX.Element
}) => ReactNode
 
type FileIconProps = {
  file: File
}
 
type UploadNativeProps = Omit<ComponentPropsWithRef<'div'>, 'onChange'>