product-shot.png
Uploaded
quarterly-report.csv
Uploading
brief.pdf
File is larger than the allowed limit
Installation
pnpm dlx shadcn-vue@latest add "https://ui.stackhacker.io/r/file-attachment.json"
Usage
<script setup lang="ts">
import { FileAttachment } from '@/components/file-attachment'
</script>
<template>
<FileAttachment
name="product-shot.png"
type="image/png"
preview-url="/uploads/product-shot.png"
status="uploaded"
removable
@remove="removeAttachment"
/>
</template>App-Owned Upload State
FileAttachment renders display-only attachment UI. Your app owns upload handlers, preview URL creation and cleanup, file limits, server state, toast messages, and removal confirmation.
Pass display-ready state through props. Use the icon, preview, or actions slots when your app needs custom file-type icons, preview rendering, or actions.
Examples
Status states
product-shot.png
Uploaded
quarterly-report.csv
Uploading
brief.pdf
File is larger than the allowed limit
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Original file name supplied by your app. |
type | string | "" | Optional MIME type used for default fallback icons. |
displayName | string | — | Optional display name. Falls back to name. |
previewUrl | string | — | Optional preview image URL supplied by your app. |
status | 'idle' | 'uploading' | 'uploaded' | 'error' | 'idle' | Display status supplied by your app. |
error | string | — | Error text shown when status is error. |
removable | boolean | false | Show a remove button when not uploading. |
removeLabel | string | 'Remove attachment' | Accessible label for the remove button. |
ariaLabel | string | — | Accessible label for the attachment. |
class | string | — | Additional CSS classes for the root element. |
Events
| Event | Payload | Description |
|---|---|---|
remove | [] | Emitted when the remove button is clicked. |
Slots
| Slot | Props | Description |
|---|---|---|
preview | { name, displayName, type, previewUrl, status } | Replace the preview area. |
icon | { name, displayName, type, status } | Replace the fallback file icon. |
actions | { name, displayName, type, previewUrl, status, remove } | Replace the remove/action area. |

