Docs menu

Guides


Primitives
Forms
Layout
Feedback
Overlays
Navigation
Data Display
AI

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.pdfPDF · 2.4 MB
  • whiteboard.pngPNG · 864 kB
  • transcript.txt0% · 18.2 kB

Details

  • The name truncates in the middle: the start ellipsises while the last few characters and the extension stay put, becausereport-v3.pdf and report-v4.pdf are 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. formatFileSize is 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.

contract-signed-2026.pdfPDF · 482 kB
Usage
<Attachment name="contract-signed-2026.pdf" size={482_000} />

Uploading

The percentage replaces the type until progress reaches 1.

dataset.csv60% · 12.8 MB
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.

design-review-notes-2026.pdfPDF · 1.3 MB
Unstyled

Same component — Kernel look stripped. See Platforms.

onRemove
previewSrc
Usage
<AttachmentList>
  <Attachment name="design-review-notes-2026.pdf" size={1250000} onRemove={remove} />
</AttachmentList>

Props

Props for Attachment.
PropTypeDefault
namestring (required)—
sizenumber (bytes)—
typestring (MIME)—
previewSrcstring (image URL)—
progressnumber (0–1)—
onRemove() => void—
removeLabelstring"Remove {name}"
localestringthe 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.