Attachment
A file chip for composers and messages: a type icon or image thumbnail, the name, the size, an optional remove button and optional upload progress. Inside an AttachmentList, a real<ul role="list">, each one renders as an<li>; on its own it's a <div>. Pair it with Composer for files waiting to be sent.
- quarterly-report-final-v3.pdf
- whiteboard.png
- transcript.txt
Details
- The name truncates in the middle: the start ellipsises while the last few characters and the extension stay put, because
report-v3.pdfandreport-v4.pdfare only told apart by their tail. The full name is one run of text for assistive tech and in the hover tooltip. - Sizes use
Intl.NumberFormat's unit style in decimal steps (2.4 MB), in the reader's locale or the one inlocale.formatFileSizeis exported. - Upload progress is a real
<progress>, a hairline along the bottom edge, labelled "Uploading {name}". - The chip has a fixed height, so its radius stops at a true half-height pill, and the thumbnail tile and remove button are concentric with its corners.
Examples
In a message
No remove button once it's sent.
Usage
<Attachment name="contract-signed-2026.pdf" size={482_000} />Uploading
The percentage replaces the type until progress reaches 1.
Usage
<Attachment name="dataset.csv" size={12_800_000} progress={0.6} />Playground
Toggle every adjustable prop and watch the component — and the code — update live.
Usage
<AttachmentList>
<Attachment name="design-review-notes-2026.pdf" size={1250000} onRemove={remove} />
</AttachmentList><kernel-attachment-list>
<kernel-attachment name="design-review-notes-2026.pdf" size="1250000" removable></kernel-attachment>
</kernel-attachment-list>Props
| Prop | Type | Default |
|---|---|---|
name | string (required) | — |
size | number (bytes) | — |
type | string (MIME) | — |
previewSrc | string (image URL) | — |
progress | number (0–1) | — |
onRemove | () => void | — |
removeLabel | string | "Remove {name}" |
locale | string | the reader's |
The custom elements are <kernel-attachment-list>and <kernel-attachment>, withpreview-src, removable andremove-label attributes. Pressing remove fires a bubbling remove event; the element doesn't remove itself, the owner of the file list does.
Accessibility
- The list restates
role="list", which Safari drops from unstyled lists. - The remove button is a real
<button>named "Remove {name}", and stays in the tab order. - The icon and thumbnail are decorative; the name is the label.
- New chips grow in with
@starting-style; under reduced motion they only fade.