Install
Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):
npx shadcn-vue@latest add https://beehexa.design/r/attachment.json
Use
<script setup lang="ts">
import { FileText, X } from '@lucide/vue'
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
AttachmentTrigger,
} from '@/components/ui/attachment'
</script>
<template>
<Attachment state="uploading">
<AttachmentTrigger as-child>
<a href="/files/invoice-10482.pdf"><span class="sr-only">Open invoice-10482.pdf</span></a>
</AttachmentTrigger>
<AttachmentMedia><FileText /></AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>invoice-10482.pdf</AttachmentTitle>
<AttachmentDescription>Uploading · 62%</AttachmentDescription>
</AttachmentContent>
<AttachmentActions>
<AttachmentAction aria-label="Remove invoice-10482.pdf"><X /></AttachmentAction>
</AttachmentActions>
</Attachment>
</template>
Props
| Part | Prop | Values | Notes |
|---|---|---|---|
Attachment |
state |
done (default), uploading, processing, error, idle |
See Usage › States |
Attachment |
size |
default, sm, xs |
Tile 40, 32 or 24 px |
Attachment |
orientation |
horizontal (default), vertical |
Vertical is a tile with the name below; actions move to the corner |
AttachmentMedia |
variant |
icon (default), image |
image fills the tile with an img |
AttachmentTrigger |
as, as-child |
element name, boolean | A button by default (type="button"); a link with as-child. Covers the card |
AttachmentAction |
variant, size |
Button variants | ghost and icon-xs (24 px) by default |
AttachmentGroup |
— | — | A row that scrolls sideways and snaps to each card |
attachmentVariants and attachmentMediaVariants are exported for custom parts.
Built on
Plain elements and the Beehexa Button, with the shadcn-vue Attachment API. Beehexa adds the styles. Differences a consumer will notice:
- The focus ring goes around the card only when the trigger has keyboard focus. Actions have their own Button ring, so the card does not show a second one.
- An image keeps full opacity while it uploads (shadcn-vue dims it to 60%).
AttachmentTriggerimportsPrimitive(the shadcn-vue file misses it) and setstype="button", so it never submits a form.AttachmentGrouppads all sides byspace.050, so the focus ring of the first and last cards is not cut off.