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.
<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>"use client";
import * as React from "react";
import { Attachment, AttachmentList } from "@/components/vin/attachment";
export function AttachmentBasic() {
const [files, setFiles] = React.useState([
{ name: "design-brief.pdf", type: "PDF", size: 2516582 },
{ name: "hero-mountains.png", type: "PNG", size: 860160, thumbnail: "/ui/media/mountains.svg" },
{ name: "lake.jpg", variant: "image" as const, thumbnail: "/ui/media/lake.svg" },
]);
return (
<AttachmentList label="Attached files" style={{ maxWidth: 560 }}>
{files.map((f) => (
<Attachment key={f.name} {...f} onRemove={() => setFiles((all) => all.filter((x) => x !== f))} />
))}
</AttachmentList>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import { ref } from "vue";
import Attachment, { AttachmentList } from "@/components/vin/attachment.vue";
const files = ref([
{ name: "design-brief.pdf", type: "PDF", size: 2516582 },
{ name: "hero-mountains.png", type: "PNG", size: 860160, thumbnail: "/ui/media/mountains.svg" },
{ name: "lake.jpg", variant: "image" as const, thumbnail: "/ui/media/lake.svg" },
]);
const remove = (name: string) => { files.value = files.value.filter((f) => f.name !== name); };
</script>
<template>
<AttachmentList label="Attached files" style="max-width: 560px">
<Attachment v-for="f in files" :key="f.name" v-bind="f" @remove="remove(f.name)" />
</AttachmentList>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Attachment from "$lib/components/vin/attachment.svelte";
import AttachmentList from "$lib/components/vin/attachment-list.svelte";
let files = $state<{ name: string; type?: string; size?: number; thumbnail?: string; variant?: "file" | "image" }[]>([
{ name: "design-brief.pdf", type: "PDF", size: 2516582 },
{ name: "hero-mountains.png", type: "PNG", size: 860160, thumbnail: "/ui/media/mountains.svg" },
{ name: "lake.jpg", variant: "image", thumbnail: "/ui/media/lake.svg" },
]);
</script>
<AttachmentList label="Attached files" style="max-width: 560px">
{#each files as f (f.name)}
<Attachment {...f} onRemove={() => (files = files.filter((x) => x !== f))} />
{/each}
</AttachmentList>Uploading and failed
A progress bar while the file uploads, then an error with retry.
<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>import { Attachment, AttachmentList } from "@/components/vin/attachment";
export function AttachmentUpload() {
return (
<AttachmentList label="Uploads" style={{ maxWidth: 560 }}>
<Attachment name="sales-q3.csv" progress={64} onRemove={() => {}} />
<Attachment name="recording.mov" error="Upload failed" onRetry={() => {}} onRemove={() => {}} />
</AttachmentList>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Attachment, { AttachmentList } from "@/components/vin/attachment.vue";
const cancel = () => {};
const retry = () => {};
</script>
<template>
<AttachmentList label="Uploads" style="max-width: 560px">
<Attachment name="sales-q3.csv" :progress="64" @remove="cancel" />
<Attachment name="recording.mov" error="Upload failed" @retry="retry" @remove="cancel" />
</AttachmentList>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Attachment from "$lib/components/vin/attachment.svelte";
import AttachmentList from "$lib/components/vin/attachment-list.svelte";
</script>
<AttachmentList label="Uploads" style="max-width: 560px">
<Attachment name="sales-q3.csv" progress={64} onRemove={() => {}} />
<Attachment name="recording.mov" error="Upload failed" onRetry={() => {}} onRemove={() => {}} />
</AttachmentList>In a sent message
Once sent, attachments are links that open or download the file.
<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>import { Attachment, AttachmentList } from "@/components/vin/attachment";
export function AttachmentSent() {
return (
<AttachmentList label="Files in this message" style={{ maxWidth: 560 }}>
<Attachment
name="lake.jpg"
variant="image"
thumbnail="/ui/media/lake.svg"
href="/ui/media/lake.svg"
style={{ ["--vin-attachment-tile" as string]: "120px" }}
/>
<Attachment name="report-2026.pdf" href="/files/report-2026.pdf" download meta="PDF · 1.1 MB · Download" />
</AttachmentList>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Attachment, { AttachmentList } from "@/components/vin/attachment.vue";
</script>
<template>
<AttachmentList label="Files in this message" style="max-width: 560px">
<Attachment
name="lake.jpg"
variant="image"
thumbnail="/ui/media/lake.svg"
href="/ui/media/lake.svg"
style="--vin-attachment-tile: 120px"
/>
<Attachment name="report-2026.pdf" href="/files/report-2026.pdf" download meta="PDF · 1.1 MB · Download" />
</AttachmentList>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Attachment from "$lib/components/vin/attachment.svelte";
import AttachmentList from "$lib/components/vin/attachment-list.svelte";
</script>
<AttachmentList label="Files in this message" style="max-width: 560px">
<Attachment name="lake.jpg" variant="image" thumbnail="/ui/media/lake.svg" href="/ui/media/lake.svg" style="--vin-attachment-tile: 120px" />
<Attachment name="report-2026.pdf" href="/files/report-2026.pdf" download meta="PDF · 1.1 MB · Download" />
</AttachmentList>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:
npx @vinish/ui add attachmentimport { Attachment, AttachmentList, formatBytes } from "@/components/vin/attachment";import Attachment, { AttachmentList, formatBytes } from "@/components/vin/attachment.vue";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.
| Prop | Values | Default | In HTML |
|---|---|---|---|
nameThe file name. Also the picture's alt text and part of each button's label. | string | — | .vin-attachment__name |
type / sizeShown as "PDF · 2.4 MB" (size is in bytes; formatBytes does the rounding). | string / number | — | .vin-attachment__meta |
metaYour own line under the name instead of type and size. | ReactNode | — | — |
variant"image" is a square picture tile. | fileimage | file | vin-attachment--image |
thumbnailA picture: replaces the icon in a file row, or fills the tile. | string | — | img.vin-attachment__thumb |
iconYour own icon instead of the file icon. | ReactNode | — | .vin-attachment__icon > svg |
href / downloadMakes it a link, for files already sent. | string / boolean | — | a.vin-attachment[href][download] |
progress0–100 while uploading: shows "Uploading… 64%" and a small progress bar. | number | — | .vin-progress.vin-progress--sm[role=progressbar] inside .vin-attachment__body |
errorThe upload failed: the message replaces the size. | ReactNode | — | vin-attachment--error |
onRemove / onRetryShow 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"] |
AttachmentListA 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, Svelte | HTML 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.
Customize
Saved in this browser. Style and accent are in the header.