Skip to main content
ninna-ui

FileUpload

A file upload component with drag & drop support, file validation, and preview.

import { FileUpload } from "@ninna-ui/forms"
pnpm add @ninna-ui/forms

Requires @ninna-ui/core (auto-installed) + CSS setup.

View source

Usage

Import and use the FileUpload component in your application.

import { FileUpload } from "@ninna-ui/forms";
export default function Example() {
return (
<FileUpload
label="Upload files"
accept="image/*"
onFilesChange={(files) => console.log(files)}
/>
);
}

Basic

Basic file upload with drag and drop.

Click to upload or drag and drop

Any file type

Drag and drop or click to upload

Image Only

Restrict uploads to image files only.

Click to upload or drag and drop

image/*

Only image files (PNG, JPG, GIF) are accepted

Multiple Files

Allow uploading multiple files at once.

Click to upload or drag and drop

.pdf, .doc, .docx

Upload up to 5 documents

Validation

File validation with size limits and rejection handling.

Click to upload or drag and drop

image/* (max 2 MB)

Only images, max 2MB, up to 3 files

Sizes

FileUpload in different sizes.

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Show File List

Control whether to display uploaded files list.

showFileList=true (default)

Click to upload or drag and drop

Any file type

Upload files to see them listed below

showFileList=false

Click to upload or drag and drop

Any file type

Files won't be displayed after upload

Allow Drag

Enable or disable drag and drop functionality.

allowDrag=true (default)

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

allowDrag=false

Click to upload

Any file type

Drag and drop is disabled

States

Different states of the file upload.

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

Click to upload or drag and drop

Any file type

React Hook Form

FileUpload works with React Hook Form using the Controller pattern.

Click to upload or drag and drop

.pdf, .doc, .docx (max 10 MB)

PDF, DOC, or DOCX up to 10MB

API Reference

Complete list of props for the FileUpload component.

Props

PropTypeDefaultDescription
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Size of the file upload component
acceptstring-Accepted file types (e.g., "image/*", ".pdf")
multiplebooleanfalseAllow multiple file selection
maxFileSizenumber-Maximum file size in bytes
maxFilesnumber10Maximum number of files
disabledbooleanfalseWhether the upload is disabled
requiredbooleanfalseWhether the field is required
invalidbooleanfalseWhether the upload is in an invalid state
onFilesChange(files: File[]) => void-Callback when files are selected
labelstring-Label for the upload area
helperTextstring-Helper text below the upload area
showFileListbooleantrueShow file list after selection
allowDragbooleantrueAllow drag and drop

Accessibility

  • Keyboard accessible — can be activated with Enter or Space
  • Uses aria-disabled and aria-invalid for disabled and invalid states
  • File input is properly labeled for screen readers via aria-label
  • File list items have accessible remove buttons with descriptive aria-label
  • Drag and drop zone is keyboard focusable with role="button"