Docs
File Input
File Input

A comprehensive file upload component with drag-and-drop support, preview functionality, validation, and multiple file handling built with Zod integration.

Upload a file for your application

Choose a file or drag and drop it here

PDF, DOCX, JPG, and PNG, up to 10 MB

Accepted formats: PDF, DOCX, JPG, PNG

Overview

The File Input component delivers a modern file upload experience with drag-and-drop functionality, visual previews, and comprehensive validation, making it essential for forms requiring file attachments. It supports both single and multiple file uploads with configurable size limits, file type restrictions, and real-time validation feedback. Perfect for creating intuitive upload interfaces that enhance user experience while ensuring data integrity.

Installation

pnpm dlx shadcn@latest add https://deltacomponents.dev/r/file-input.json

Usage

"use client"
 
import { FileInput } from "@/registry/inputs/file-input"
 
export function Component() {
  return (
    <FileInput
      label="Upload Document"
      name="document"
      accept=".pdf,.docx,.jpg,.png"
      multiple
      maxSize={10 * 1024 * 1024} // 10MB
      hint="Accepted formats: PDF, DOCX, JPG, PNG"
      onFilesSelected={(files) => console.log(files)}
    />
  )
}

API Reference

Props

PropTypeDefaultDescription
labelstring-Label for the file input field (required)
namestring-Name of the input field for form submission (required)
descriptionstringundefinedDescription text below the label
hintstringundefinedHint text below the file input
errorstringundefinedError message to display
requiredbooleanfalseWhether the field is required
pendingbooleanfalseWhether the field is in a loading state
acceptstringundefinedAccepted file types (e.g., ".pdf,.jpg,image/*")
multiplebooleanfalseWhether to accept multiple files
maxSizenumberundefinedMaximum file size in bytes
maxFilesnumber5Maximum number of files (when multiple is true)
disabledbooleanfalseWhether the input is disabled
idstringnameID for the file input element
variant"default" | "pill""default"Visual variant of the input
coloredBorderbooleanfalseWhether to show colored border (pill variant)
labelVariant"default" | "muted""default"Label text styling variant
containerClassNamestring""CSS classes for the container
dropzoneClassNamestring""CSS classes for the file drop area
labelClassNamestring""CSS classes for the label
dropzoneTextstringundefinedCustom text for the dropzone
showPreviewsbooleantrueWhether to show file previews
showIconsbooleantrueWhether to show file type icons
schemaZodType<File | File[]>undefinedZod schema for validation
onValidate(isValid: boolean, files: File | File[], error?: string) => voidundefinedValidation callback
onFilesSelected(files: File[]) => voidundefinedCallback when files are selected

Examples

Pill Variant

Rounded pill variant with muted background styling and colored border.

Choose a file or drag and drop it here

JPG, PNG, and PDF, up to 10 MB

Pill variant with colored border

Multiple Files

Upload multiple files with drag and drop support and configurable limits.

Choose a file or drag and drop it here

PDF, JPG, PNG, and DOCX, up to 10 MB

You can upload up to 5 files

File Previews

Upload files with visual previews for images and type icons for documents.

Choose a file or drag and drop it here

IMAGE, PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, MP3, and MP4, up to 10 MB

Upload different file types to see their custom SVG icons: Word docs, Excel files, PDFs, PowerPoint, MP3/MP4 files, and images