# 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](/components/composer/) for files waiting to be sent.

## Details

- The name truncates in the middle: the start ellipsises while the last few characters and the extension stay put, because `report-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 in `locale`. `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.

### Uploading

The percentage replaces the type until progress reaches 1.

## Playground

Toggle every adjustable prop and watch the component — and the code — update live.

## 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>`, with `preview-src`, `removable` and `remove-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.
