Forms

Upload queue.

Queue each file, follow its transfer and recover one request at a time.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/upload-queue.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.

Process files locally

This handler reads and hashes local files. It demonstrates queue callbacks without pretending to upload or store anything.

Loads this example when you need it.

Keyboard

  • Tab reaches Browse, Start and each file action.
  • Cancel aborts the local attempt.

States covered

  • Queued
  • Locally processing
  • Receipt
  • Cancelled

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-upload-queue.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 {UploadQueue,type UploadFileHandler} from '@bld8/ui';
import '@bld8/ui/styles.css';
const processFile:UploadFileHandler=async(file,{signal,requestId,onProgress})=>{
  const bytes=await file.arrayBuffer();if(signal.aborted)throw new DOMException('Cancelled','AbortError');
  const digest=await crypto.subtle.digest('SHA-256',bytes);if(signal.aborted)throw new DOMException('Cancelled','AbortError');
  onProgress({loaded:file.size,total:file.size});
  const sha256=Array.from(new Uint8Array(digest),value=>value.toString(16).padStart(2,'0')).join('');
  return {id:'local-'+requestId,requestId,bytes:file.size,sha256};
};
export default function QueueExample(){return <div><p>No files leave this browser. The handler reads and hashes each file locally; this is not an upload service.</p><UploadQueue label="Example local file processor" onUploadFile={processFile} maxFiles={3} maxSize={2*1024*1024} concurrency={1}/></div>;}

Wait for a per-file acknowledgement

Read and hash real local file bytes, then hold the handler promise until the local adapter acknowledges or rejects each receipt. Cancel and retry keep a stable request ID.

Keyboard

  • Browse files and Start queued are available by keyboard.
  • Use the file Cancel or Retry action; focus follows the surviving row action.
  • Acknowledge or Reject processed files resolves the local adapter outside the queue.

States covered

  • Measured local bytes
  • Processing while awaiting a receipt
  • Cancellation through AbortSignal
  • Rejected acknowledgement
  • Retry with stable request ID
  • No network or durable storage

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-workflow-upload-acknowledgement.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 '@bld8/ui/styles.css';
import { useCallback, useEffect, useRef, useState } from 'react';
import { UploadQueue } from '@bld8/ui/upload-queue';
import type { UploadFileHandler, UploadQueueItem, UploadReceipt } from '@bld8/ui/upload-state';
import { Button } from '@bld8/ui/core';

type PendingReceipt = { accept: () => void; reject: () => void };
export function AcknowledgedFileProcessingExample() {
  const [items, setItems] = useState<readonly UploadQueueItem[]>([]);
  const [waiting, setWaiting] = useState(0);
  const pending = useRef(new Map<string, PendingReceipt>()), alive = useRef(true);
  useEffect(() => { alive.current = true; return () => { alive.current = false; }; }, []);
  const processFile = useCallback<UploadFileHandler>(async (file, { signal, requestId, onProgress }) => {
    const reader = file.stream().getReader();
    const chunks: Uint8Array<ArrayBuffer>[] = [];
    let loaded = 0;
    const cancelReader = () => { void reader.cancel().catch(() => {}); };
    signal.addEventListener('abort', cancelReader, { once: true });
    try {
      while (true) {
        if (signal.aborted) throw new DOMException('Cancelled', 'AbortError');
        const next = await reader.read(); if (next.done) break;
        chunks.push(new Uint8Array(next.value)); loaded += next.value.byteLength; onProgress({ loaded, total: file.size });
      }
    } finally { signal.removeEventListener('abort', cancelReader); reader.releaseLock(); }
    if (signal.aborted) throw new DOMException('Cancelled', 'AbortError');
    const bytes = new Uint8Array(loaded); let offset = 0;
    for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.length; }
    const digest = await crypto.subtle.digest('SHA-256', bytes);
    if (signal.aborted) throw new DOMException('Cancelled', 'AbortError');
    onProgress({ loaded: file.size, total: file.size });
    const receipt: UploadReceipt = { id: 'local-' + requestId, requestId, bytes: file.size, sha256: Array.from(new Uint8Array(digest), value => value.toString(16).padStart(2, '0')).join('') };
    return new Promise<UploadReceipt>((resolve, reject) => {
      const cleanup = () => { pending.current.delete(requestId); signal.removeEventListener('abort', abort); if (alive.current) setWaiting(pending.current.size); };
      const abort = () => { cleanup(); reject(new DOMException('Cancelled', 'AbortError')); };
      if (signal.aborted) { abort(); return; }
      signal.addEventListener('abort', abort, { once: true });
      pending.current.set(requestId, { accept: () => { cleanup(); resolve(receipt); }, reject: () => { cleanup(); reject(new Error('Local receipt rejected')); } });
      if (alive.current) setWaiting(pending.current.size);
    });
  }, []);
  return <div style={{ width: '100%', display: 'grid', gap: 20 }}>
    <p className="bui-hint">No files leave this browser. The local adapter reads and hashes bytes, then waits for your acknowledgement. It does not upload or store files.</p>
    <UploadQueue label="Acknowledged local processing" onUploadFile={processFile} onItemsChange={setItems} maxFiles={3} maxSize={256 * 1024} concurrency={1} />
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}><Button disabled={!waiting} onClick={() => { for (const receipt of [...pending.current.values()]) receipt.accept(); }}>Acknowledge processed files</Button><Button variant="secondary" disabled={!waiting} onClick={() => { for (const receipt of [...pending.current.values()]) receipt.reject(); }}>Reject processed files</Button></div>
    <p role="status">{waiting} file acknowledgement{waiting === 1 ? '' : 's'} pending.</p>
    <output aria-label="Upload attempt records" className="bui-hint" style={{ overflowWrap: 'anywhere' }}>{JSON.stringify(items.map(item => ({ requestId: item.requestId, attempt: item.attempt, status: item.status })))}</output>
  </div>;
}

Quick reference

React / TypeScript
<UploadQueue label="Files" onUploadFile={uploadFile}
  maxFiles={5} concurrency={2} />

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

Per-file queued, uploading, processing, acknowledged, failed and cancelled states. Start explicitly by default; retries retain a request ID and resend the complete file. The supplied handler receives AbortSignal and byte-progress callbacks and must return a matching receipt. createUploadHttpAdapter uses real XHR upload events with a bounded JSON acknowledgement. Sending every byte is Processing; only the receipt completes a file. Up to 20 files, 100 MiB per file and three concurrent requests are configurable. The demo receiver has a separate 2 MiB limit, hashes and discards bytes and retains temporary per-session receipts. The host owns authentication, storage, server validation and resumability. See /integrations/uploads and /agent/guides/upload-workflows.md.

Try real per-file transfers · Queue and transport contract

UploadQueue

UploadQueue public properties
PropTypeDefault
labelRequiredstring—
onUploadFileRequiredUploadFileHandler—
acceptstring | undefined''
autoStartboolean | undefinedfalse
concurrencynumber | undefined2
disabledboolean | undefinedfalse
hintstring | undefined—
maxFilesnumber | undefined5
maxSizenumber | undefined10*1024*1024
onItemsChange((items: readonly UploadQueueItem[]) => void) | undefined

Observational snapshots; Files and receipts are not persisted by the queue.

—

UploadQueueItem

UploadQueueItem public properties
PropTypeDefault
attemptRequirednumber—
fileRequiredFile—
idRequiredstring—
loadedRequirednumber—
requestIdRequiredstring—
statusRequiredUploadStatus—
errorstring | undefined—
receiptUploadReceipt | undefined—
totalnumber | undefined—

UploadStatus

'queued'|'uploading'|'processing'|'complete'|'error'|'cancelled'

UploadFileContext

UploadFileContext public properties
PropTypeDefault
onProgressRequired(progress: UploadProgress) => void—
requestIdRequiredstring—
signalRequiredAbortSignal—

UploadProgress

UploadProgress public properties
PropTypeDefault
loadedRequirednumber—
totalnumber | undefined—

UploadReceipt

UploadReceipt public properties
PropTypeDefault
bytesRequirednumber—
idRequiredstring—
requestIdRequiredstring—
sha256string | undefined—

UploadHttpOptions

UploadHttpOptions public properties
PropTypeDefault
endpointRequiredstring—
headersReadonly<Record<string, string>> | (() => Readonly<Record<string, string>>) | undefined

The host owns authorisation, session scope and CORS configuration.

—
timeoutMsnumber | undefined—
withCredentialsboolean | undefined—

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.