One file, drawn as a square
A picture fills the tile. A well-known document format wears a coloured mark, and every other file wears its extension as a neutral badge. Under the mark sit the name, cut in the middle so the extension survives, and one line for the size or the state. The same tile serves a composer’s queue and a sent message.
Every kind, every state
Each row is a kind of file and each column is a state. The mark, the spinner and the state icons all fill the same square at the same seat, so a file changing state never moves anything.
Well-known formats
PDFs, spreadsheets, documents and presentations each keep the colour they are known by, in every theme. The lettering under the mark is drawn in a text colour, so it stays readable whatever the format colour is.
Everything else
Any other file wears its extension as a neutral badge. Colour stays a signal for the formats a reader recognises at a glance.
Previews
A picture fills the tile. A document can do the same with a first page the host has rendered, and keeps its format as a badge over the corner. The library draws no documents itself: pass the image in.
Removable and clickable
Click and remove are separate controls, so opening a file never fights with detaching it. The remove button appears on hover and on focus, and stays visible on a file that failed. Try removing these.
Compact
Compact shrinks the square and drops the second line of a ready file, for a dense thread.
Alternatives
- Use File row instead when the file is one of a list of documents, read as rows.
Props
Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
name* | string | File name, extension included. Truncates in the middle so the extension stays visible. | |
kind | FileKind | 'generic' | What kind of file it is, which picks the type mark: a coloured lettered
glyph for the well-known formats, a neutral extension badge for the
rest. Derive it with `getFileKind`. |
typeLabel | string | Short uppercase label on the type mark. Defaults from the kind and the extension. | |
status | AttachmentStatus | 'ready' | Where the file is in its life. Anything but `ready` shows the name with a status line. |
progress | number | Upload progress, 0 to 100, reported to assistive technology while `uploading`. | |
previewSrc | string | Image that fills the tile while `ready`: an object URL for a picture, or
a first page the host rendered for a document. A non-image kind keeps
its type mark over the corner. | |
previewAlt | string | Alt text for the preview. Defaults to the file name. | |
previewMark | boolean | Whether the type mark sits over the corner of a preview. Defaults to on
for a document's first page, which still has to say what format it is,
and off for a picture, which is its own description. A sent message
turns it on for pictures too. | |
excerpt | string | First lines of a pasted block, drawn as a faded excerpt filling the tile while `ready`. | |
meta | string | Secondary line under the name while `ready`, e.g. "1.2 MB". Callers keep their own formatting. | |
error | string | Why the file failed. Replaces `errorLabel` on the status line. | |
size | "default" | "compact" | 'default' | Tile size. Compact shrinks the square and drops the secondary line of a
ready file. Unrelated to any native `size` attribute: the root is a div. |
onClick | MouseEventHandler<HTMLButtonElement> | Click handler. Its presence makes the tile body a button. | |
onRemove | (() => void) | Remove handler. Its presence renders the corner remove button. | |
uploadingLabel | string | 'Uploading…' | Status line while `uploading`. |
errorLabel | string | 'Upload failed' | Status line while `error`, when no `error` message is given. |
unavailableLabel | string | 'Unavailable' | Status line while `unavailable`. |
removeLabel | string | Accessible label for the remove button. Defaults to "Remove" and the file name. | |
progressLabel | ((name: string) => string) | (fileName: string) => `Uploading ${fileName}` | Accessible name of the upload progress spinner while `uploading`, given the file name. Defaults to "Uploading" followed by the name. |
className | string | '' | Additional CSS classes |
Keys
Nothing here takes focus, so there are no keys. A test holds that.
// From the npm package
import { AttachmentTile } from 'rift-ds/components/AttachmentTile/AttachmentTile';
// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/attachment-tile.json3.1 kB gzipped, with everything it imports. Peer dependencies are not counted.
For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.

