FileList
A list of files with upload status, progress and file actions.
beta
Try it
- No files
<FileList />Examples
Attachments
- invoice-november.pdf48,200 byte Done
<script lang="ts">
import FileList from '@tcpsystems/ui/foundation/FileList';
let files = $state([{ name: 'invoice-november.pdf', size: 48200, state: 'done' as const }]);
</script>
<FileList {files} onremove={(name) => files = files.filter(file => file.name !== name)} />Upload states
- release-notes.txt1,200 byte Queued
- deployment.log64,000 byte Uploading
- trace.json8,400 byte Uploading
- invoice.pdf48,200 byte Error Connection lost. Retry the upload.
<script lang="ts">
import FileList from '@tcpsystems/ui/foundation/FileList';
import Button from '@tcpsystems/ui/foundation/Button';
import Stack from '@tcpsystems/ui/foundation/Stack';
type Upload = { name: string; size: number; state: 'queued' | 'uploading' | 'done' | 'error'; progress?: number; error?: string };
let files = $state<Upload[]>([
{ name: 'release-notes.txt', size: 1200, state: 'queued' },
{ name: 'deployment.log', size: 64000, state: 'uploading', progress: 45 },
{ name: 'trace.json', size: 8400, state: 'uploading' },
{ name: 'invoice.pdf', size: 48200, state: 'error', error: 'Connection lost. Retry the upload.' }
]);
</script>
<Stack>
<FileList {files} onremove={(name) => files = files.filter(file => file.name !== name)}
onretry={(name) => files = files.map(file => file.name === name ? { ...file, state: 'queued', error: undefined } : file)} />
<Button onclick={() => files = files.map(file => ({ ...file, state: 'done', error: undefined }))}>Mark uploads complete</Button>
</Stack>Empty
- No files
<script lang="ts">
import FileList from '@tcpsystems/ui/foundation/FileList';
</script>
<FileList />API
import FileList from '@tcpsystems/ui/foundation/FileList';| Prop | Type | Default |
|---|---|---|
files? | File[] | [] |
removeLabel? | (name: string) => string | (name: string) => `Remove ${name}` |
retryLabel? | (name: string) => string | (name: string) => `Retry ${name}` |
| Hook | Kind |
|---|---|
.tcp-file-list | Root class |
data-state | Data attribute |