Attachment

A file in a composer, upload list or chat: thumbnail or type icon, name, size, upload progress, error, remove and download.

Source on GitHub

Code

API

For AI agents: this API as Markdown, or every component in llms-full.txt.

<ray-attachment>

Assign a File to `file` to fill name, size, type and an image thumbnail. Removing it (× button) fires a cancelable ray-remove and then removes the element.

PropertyAttributeTypeDefaultDescription
namename reflectsstringFile name (ellipsized; full name in the tooltip).
sizesizenumberSize in bytes, shown as "12 KB", "3.4 MB".
typetype reflectsstringMIME type: picks the icon (image or file) and, with the name, the extension badge.
srcsrcstringThumbnail URL for images (falls back to the icon if it fails to load).
hrefhref reflectsstringMakes the name a download link.
progressprogressnumberUpload progress 0–100: a thin bar and "Uploading… 45%". Unset: done.
statusstatus reflectsuploading | done | errorExplicit state. Default: "uploading" while progress is set, else "done".
errorerrorstringError text shown with status="error" (default "Upload failed").
removableremovable reflectsbooleanShows a remove (×) button.
removeLabelremove-labelstringRemove {name} (text attachment.remove)Accessible label of the remove button; {name} is replaced by the file name.
variantvariant reflectsrow | cardrowrow: a compact chip; card: the thumbnail on top.
disableddisabled reflectsbooleanDimmed, not removable, the name is not a link.
EventDescription
ray-removeThe remove button was pressed; cancelable (preventDefault keeps the element).
PartDescription
itemThe box.
thumbnailThe thumbnail or icon box.
badgeThe extension badge (PDF, PNG…).
nameThe file name (a link with href).
metaSize, upload state or error.
progressThe upload progress bar.
removeThe remove button.

<ray-attachments>

A wrapping row of ray-attachment elements.

SlotDescription
(default)ray-attachment elements.

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
attachment.removeRemove {name}
attachment.uploadingUploading…
attachment.uploading-percentUploading… {percent}%
attachment.progressUploading {name}
attachment.failedUpload failed