File list

Slant / Data

A list of attachments with upload progress, retries and failures.

Demo

Attachments

Usage

@tuttn/slant
import { FileItem, FileList } from '@tuttn/slant'

<FileList aria-label="Attachments">
  <FileItem name="agent-handoff.md" type="MD" size="12 KB" progress={100} />
  <FileItem name="eval-results.csv" type="CSV" size="2.4 MB" progress={38} />
  <FileItem name="model-weights.safetensors" type="BIN" size="1.8 GB" progress={61} status="failed" onRetry={retry} />
</FileList>

// From your upload state: key each item by something stabler than its name.
<FileList aria-label="Attachments">
  {uploads.map(upload => <FileItem key={upload.id} name={upload.name} type={upload.type}
    size={upload.size} progress={upload.progress} status={upload.status} onRetry={() => retry(upload.id)} />)}
</FileList>

Props

PropTypeDefaultDescription
…restHTMLAttributes<HTMLUListElement>—children (the FileItems), className, style, other attributes and the ref go on the ul.

Accessibility

  • FileList is a ul and each FileItem an li. Name the list with aria-label when the page has more than one.
  • Safari can drop the list role from a list without bullets, so VoiceOver may not say how many files there are. Add role="list" if that count matters.
  • Each item's status line is a polite live region, so changes are announced: the percent as it climbs, then "Uploaded" or "Upload failed".
  • An empty FileList is an empty list. Show a line of text instead, as the demo does.

FileList holds no state and has no props of its own: it lays out its FileItems with a small gap. Adding, ordering and removing files is up to you. Each item's props are on the File item page.

Full source