Skip to content
VinUIComponentsAttachment

Attachment

A file or picture attached to a message: an icon or thumbnail, the name, its size and type, and an optional remove button. Shows upload progress and failed uploads too. Same markup and props in every style: switch the style in the header to see it change.

Basic

Files waiting to be sent: a document, one with a thumbnail and a picture tile, each with a remove button.

  • design-brief.pdf PDF · 2.4 MB
  • hero-mountains.png PNG · 840 KB
  • lake.jpg
attachment-basic.html
<ul class="vin-attachment-list" aria-label="Attached files" style="max-width: 560px">
  <li>
    <div class="vin-attachment">
      <span class="vin-attachment__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6"/><path d="M9 17h4"/></svg></span>
      <span class="vin-attachment__body">
        <span class="vin-attachment__name">design-brief.pdf</span>
        <span class="vin-attachment__meta">PDF · 2.4 MB</span>
      </span>
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Remove design-brief.pdf"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
    </div>
  </li>
  <li>
    <div class="vin-attachment">
      <img class="vin-attachment__thumb" src="/ui/media/mountains.svg" alt="">
      <span class="vin-attachment__body">
        <span class="vin-attachment__name">hero-mountains.png</span>
        <span class="vin-attachment__meta">PNG · 840 KB</span>
      </span>
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Remove hero-mountains.png"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
    </div>
  </li>
  <li>
    <div class="vin-attachment vin-attachment--image">
      <img class="vin-attachment__thumb" src="/ui/media/lake.svg" alt="lake.jpg">
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Remove lake.jpg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
    </div>
  </li>
</ul>

Uploading and failed

A progress bar while the file uploads, then an error with retry.

  • sales-q3.csv Uploading… 64%
  • recording.mov Upload failed
attachment-upload.html
<ul class="vin-attachment-list" aria-label="Uploads" style="max-width: 560px">
  <li>
    <div class="vin-attachment">
      <span class="vin-attachment__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6"/><path d="M9 17h4"/></svg></span>
      <span class="vin-attachment__body">
        <span class="vin-attachment__name">sales-q3.csv</span>
        <span class="vin-attachment__meta">Uploading… 64%</span>
        <span class="vin-progress vin-progress--sm" role="progressbar" aria-label="Uploading sales-q3.csv" aria-valuemin="0" aria-valuemax="100" aria-valuenow="64" style="--vin-value: 64%"></span>
      </span>
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Cancel upload of sales-q3.csv"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
    </div>
  </li>
  <li>
    <div class="vin-attachment vin-attachment--error">
      <span class="vin-attachment__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M12 11v3.5"/><path d="M12 17.5h.01"/></svg></span>
      <span class="vin-attachment__body">
        <span class="vin-attachment__name">recording.mov</span>
        <span class="vin-attachment__meta">Upload failed</span>
      </span>
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Retry recording.mov"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg></button>
      <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon vin-attachment__action" aria-label="Remove recording.mov"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
    </div>
  </li>
</ul>

In a sent message

Once sent, attachments are links that open or download the file.

attachment-sent.html
<ul class="vin-attachment-list" aria-label="Files in this message" style="max-width: 560px">
  <li>
    <a class="vin-attachment vin-attachment--image" href="/ui/media/lake.svg" style="--vin-attachment-tile: 120px">
      <img class="vin-attachment__thumb" src="/ui/media/lake.svg" alt="lake.jpg">
    </a>
  </li>
  <li>
    <a class="vin-attachment" href="/files/report-2026.pdf" download>
      <span class="vin-attachment__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6"/><path d="M9 17h4"/></svg></span>
      <span class="vin-attachment__body">
        <span class="vin-attachment__name">report-2026.pdf</span>
        <span class="vin-attachment__meta">PDF · 1.1 MB · Download</span>
      </span>
    </a>
  </li>
</ul>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add attachment
React
import { Attachment, AttachmentList, formatBytes } from "@/components/vin/attachment";
Vue
import Attachment, { AttachmentList, formatBytes } from "@/components/vin/attachment.vue";
Svelte
import Attachment, { formatBytes } from "$lib/components/vin/attachment.svelte";
import AttachmentList from "$lib/components/vin/attachment-list.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/attachment.json, which every framework version is tested against.

PropValuesDefaultIn HTML
name
The file name. Also the picture's alt text and part of each button's label.
string—.vin-attachment__name
type / size
Shown as "PDF · 2.4 MB" (size is in bytes; formatBytes does the rounding).
string / number—.vin-attachment__meta
meta
Your own line under the name instead of type and size.
ReactNode——
variant
"image" is a square picture tile.
fileimagefilevin-attachment--image
thumbnail
A picture: replaces the icon in a file row, or fills the tile.
string—img.vin-attachment__thumb
icon
Your own icon instead of the file icon.
ReactNode—.vin-attachment__icon > svg
href / download
Makes it a link, for files already sent.
string / boolean—a.vin-attachment[href][download]
progress
0–100 while uploading: shows "Uploading… 64%" and a small progress bar.
number—.vin-progress.vin-progress--sm[role=progressbar] inside .vin-attachment__body
error
The upload failed: the message replaces the size.
ReactNode—vin-attachment--error
onRemove / onRetry
Show a remove (or cancel) button, and a retry button after an error.
() => void—button.vin-btn.vin-btn--ghost.vin-btn--icon.vin-attachment__action[aria-label="Remove name"]
AttachmentList
A wrapping row of attachments, e.g. above the message box. label names the list.
children—ul.vin-attachment-list[aria-label] > li > .vin-attachment

Parts

React, Vue, SvelteHTML classes
<Attachment><AttachmentList>.vin-attachment.vin-attachment--error.vin-attachment--image.vin-attachment__icon.vin-attachment__thumb.vin-attachment__body.vin-attachment__name.vin-attachment__meta.vin-attachment__action.vin-attachment-list

Accessibility

  • Attachments sit in a labelled list, so screen readers say how many files there are.
  • Every button names its file: "Remove design-brief.pdf", "Retry recording.mov".
  • Upload progress is a progressbar named after the file, with its value. The error is plain text next to the name, and is shown by an icon and a red edge, not colour alone.
  • A picture tile uses the file name as its alt text; thumbnails in a file row are decorative (alt="") because the name is right next to them.