A file attached to a chat message, as a chip with its preview, name, size, and a remove button. Use it in Prompt Input for a draft, and under a sent message.
When to use
- Show the files attached to a chat message, with a remove button while the message is a draft.
- Leave out
Attachment.Removewhere a file cannot be removed, such as in a sent message. - Use Prompt Input to take the files.
A file the app still reads
Set busy on Attachment.Root while your app reads a file, and show a Skeleton in place of Attachment.Preview. The chip sets aria-busy.
Set data-slot="attachment-preview" on the skeleton so it occupies the preview's grid cell.
Composition
Polymorphism
Attachment.List, Attachment.Root, and Attachment.Name take asChild. Attachment.Preview picks between an image and an icon, Attachment.Size renders its own text, and Attachment.Remove owns its icon, so those three do not.
Translation
Attachment.Name sets translate="no", because a file name is an identifier.
API Reference
Attachment.List
The list of attached files, as chips that wrap. Name it, such as aria-label="Attachments".
All props from ul, plus:
Attachment.Root
One attached file. The chip lays out its parts by their data-slot: the preview on the left, the name over the size, and the remove button on the right.
All props from li, plus:
Attachment.Preview
A 32-pixel thumbnail of an image file, or a file icon when src is not set. It is decorative.
All props from img except alt, width, and height.
Attachment.Name
The file's name. It truncates when the chip is narrow, and never translates. Set title to show the whole name on hover.
All props from span except translate, plus:
Attachment.Size
The file's size, such as "1.5 KB".
All props from span except children, plus:
Attachment.Remove
The button that removes a file from a draft message. Name the file in the required label, such as "Remove report.pdf".
All props from Icon Button except appearance, asChild, icon, intent, and type. label is required.