Forms

File upload.

Browse or drop files, validate them and connect your own transport.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/file-upload.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Choose local files without sending them

Selection, validation and removal work locally; no upload callback or network service is supplied.

Loads this example when you need it.

Keyboard

  • Tab reaches Browse and each file removal action.

States covered

  • Empty
  • Chosen files
  • Validation feedback

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-file-upload.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {FileUpload} from '@bld8/ui';
import '@bld8/ui/styles.css';
export default function LocalFilesExample(){const [files,setFiles]=useState<File[]>([]);return <div><FileUpload label="Example local attachments" accept=".txt,.pdf" maxFiles={3} maxSize={2*1024*1024} value={files} onValueChange={setFiles} hint="Files stay on this device. No upload service is connected."/><p>{files.length} local files selected</p></div>;}

Quick reference

React / TypeScript
<FileUpload label="Attachments" accept=".pdf,.png" maxFiles={3}
  maxSize={5 * 1024 * 1024} value={files} onValueChange={setFiles}
  onUpload={(files,{signal,onProgress}) => uploadFiles(files,{signal,onProgress})} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Native browsing, drag/drop, duplicate detection, type/size/count checks and removal. Files remain local unless onUpload is supplied. That async callback receives an AbortSignal and per-file onProgress(file,percent). Failure allows retry, cancellation aborts and stale completions are ignored. Frontend checks are convenience only; validate content, size and access on the server. The showcase callback mode is explicitly a simulation.

FileUpload

FileUpload public properties
PropTypeDefault
labelRequiredstring—
acceptstring | undefined''
defaultValueFile[] | undefined[]
disabledboolean | undefined—
hintstring | undefined—
maxFilesnumber | undefined5
maxSizenumber | undefined10 * 1024 * 1024
onUpload((files: globalThis.File[], context: UploadContext) => Promise<void>) | undefined

Supply your upload service. No request is made without this callback.

—
onValueChange((files: globalThis.File[]) => void) | undefined—
valueFile[] | undefined—

UploadContext

UploadContext public properties
PropTypeDefault
onProgressRequired(file: globalThis.File, percent: number) => void—
signalRequiredAbortSignal—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.