Skip to content

FileUpload

import { FileUpload } from '@delightstack/components';

Drop files here or browse

Images only

View code
<script>
import { FileUpload } from '@delightstack/components';
let files = $state<File[]>([]);
</script>
<FileUpload bind:files accept="image/*" label="Upload images" />

A large dashed-border area that accepts drag-and-drop or click-to-browse.

Drop files here or browse

Images only

View code
<FileUpload accept="image/*" multiple label="Upload images" />

A button-style trigger with a file list rendered below.

View code
<FileUpload compact accept="image/*,application/pdf" multiple />

A circular upload area for profile pictures. Automatically single-file only.

View code
<FileUpload avatar accept="image/*" />

Validate file type, size, and count. Errors are reported per file via the onerror callback.

Drop files here or browse

PDF, DOC, or DOCX

View code
<FileUpload
bind:files
accept=".pdf,.doc,.docx"
max_size={10 * 1024 * 1024}
max_files={3}
multiple
label="Upload documents (PDF, DOC — max 3 files, 10MB each)"
/>

Use the file_item snippet to customize how each file appears in the list. Useful for showing upload progress or custom layouts.

Drop files here or browse

View code
<script>
import { FileUpload } from '@delightstack/components';
let files = $state([]);
</script>
<FileUpload bind:files multiple label="Upload files">
{#snippet file_item({ file, index, remove })}
<div style="display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--color-border); border-radius: 0.375rem; margin-top: 0.5rem;">
<span style="flex: 1;">{file.name} ({(file.size / 1024).toFixed(1)} KB)</span>
<button onclick={remove}>Remove</button>
</div>
{/snippet}
</FileUpload>

Drop files here or browse

Images only

View code
<FileUpload accept="image/*" error="Please upload at least one image" />
PropTypeDefaultDescription
filesFile[][]Selected files, bindable
acceptstring-Accepted file types (e.g. 'image/*', '.pdf,.doc')
multiplebooleanfalseAllow multiple files
max_sizenumber-Max file size in bytes
max_filesnumber-Max number of files
disabledbooleanfalseDisable upload
previewbooleantrueShow image thumbnails in file list
dropzonebooleantrueLarge drop target variant (default)
compactbooleanfalseButton-style trigger variant
avatarbooleanfalseCircular avatar upload variant
size'0' | '1' | '2''1'Component size
skeletonbooleanfalseShow skeleton loading state
labelstring-Instruction text / accessible label
errorstring-Global error message
densebooleanfalseCompact internal padding
comfortablebooleanfalseRelaxed internal padding
idstringautoElement ID
namestring-Form field name
classstring''Additional CSS classes
file_itemSnippet<[{ file, index, remove }]>-Custom file list item rendering
EventDetailDescription
onselect{ files: File[] }Files selected (via click or drop)
onremove{ file: File, index: number }File removed from list
onerror{ file: File, error: string }File validation failed
  • Keyboard navigation: Tab to focus, Enter/Space to open file picker
  • aria-label on the drop zone describes the action
  • Each file in the list has a labeled remove button
  • Focus management after file selection
  • Drag-and-drop provides visual feedback with border and background color changes