Components / Conversation
Attachment
A file or media card with upload and error states.
<div class="attachment">
<div data-slot="media"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg></div>
<div data-slot="content">
<span data-slot="title">report.pdf</span>
<span data-slot="description">PDF · 2.4 MB</span>
</div>
<div data-slot="actions">
<button type="button" class="btn" data-variant="ghost" data-size="icon-xs" aria-label="Remove report.pdf">×</button>
</div>
</div>Installation
pnpm dlx loseta add attachmentnpx loseta add attachmentExamples
States
<div style="display: flex; flex-direction: column; gap: 0.75rem; max-width: 24rem">
<div class="attachment">
<div data-slot="media"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg></div>
<div data-slot="content">
<span data-slot="title">report.pdf</span>
<span data-slot="description">PDF · 2.4 MB</span>
</div>
<div data-slot="actions">
<button type="button" class="btn" data-variant="ghost" data-size="icon-xs" aria-label="Remove report.pdf">×</button>
</div>
</div>
<div class="attachment" aria-busy="true">
<div data-slot="media"><span class="spinner" data-size="sm"></span></div>
<div data-slot="content">
<span data-slot="title">sales-dashboard.csv</span>
<span data-slot="description">Uploading · 64%</span>
</div>
</div>
<div class="attachment">
<div data-slot="media"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg></div>
<div data-slot="content">
<span data-slot="title">workspace.zip</span>
<span data-slot="description" role="alert">Upload failed. The file is larger than 10 MB.</span>
</div>
</div>
</div>Media
<div class="attachment" data-orientation="vertical">
<div data-slot="media">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 90'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop stop-color='%2394a3b8'/%3E%3Cstop offset='1' stop-color='%23e2e8f0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='90' fill='url(%23g)'/%3E%3Ctext x='80' y='49' text-anchor='middle' font-family='sans-serif' font-size='12' fill='%23334155'%3E16:9%3C/text%3E%3C/svg%3E" alt="Workspace preview">
</div>
<div data-slot="content">
<span data-slot="title">cover.png</span>
<span data-slot="description">PNG · 840 KB</span>
</div>
<div data-slot="actions">
<button type="button" class="btn" data-variant="secondary" data-size="icon-xs" aria-label="Remove cover.png">×</button>
</div>
</div>Accessibility and behavior
- Use aria-busy="true" while uploading or processing. Put an error in [data-slot="description"] with role="alert"; the root styles it through :has(). Media, content and actions use data-slot. An optional [data-slot="trigger"] overlay keeps actions above the hit area.
Files
components/attachment.cssbasestyles/nova/attachment.cssstyleInstall contract
The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.