General
Attachment
Usage#
import { WDS_ATTACHMENT } from '@wds/angular/attachment';Examples#
Default#
wds-attachment-actions.
import { Component } from '@angular/core';
import { WdsAttachmentActionsComponent, WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent } from '@wds/angular/attachment';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/file-text';
import '@wds/core/icons/lucide/download';
@Component({
selector: 'app-attachment-default-demo',
imports: [WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentActionsComponent, WdsIconComponent, WdsButtonComponent],
template: `
<div class="w-full max-w-sm">
<wds-attachment class="w-full">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>timetable-2026.pdf</wds-attachment-title>
<wds-attachment-description>PDF · 2.4 MB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Download timetable-2026.pdf" icon="lucide-download"></wds-button>
</wds-attachment-actions>
</wds-attachment>
</div>
`,
})
export class AttachmentDefaultDemo {}Sizes#
sm and xs (a chip, e.g. in a message composer).
import { Component } from '@angular/core';
import { WdsAttachmentActionsComponent, WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent } from '@wds/angular/attachment';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/file-text';
import '@wds/core/icons/lucide/download';
import '@wds/core/icons/lucide/file-spreadsheet';
import '@wds/core/icons/lucide/x';
@Component({
selector: 'app-attachment-sizes-demo',
imports: [WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentActionsComponent, WdsIconComponent, WdsButtonComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-3">
<wds-attachment>
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>station-report.pdf</wds-attachment-title>
<wds-attachment-description>PDF · 1.1 MB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Download station-report.pdf" icon="lucide-download"></wds-button>
</wds-attachment-actions>
</wds-attachment>
<wds-attachment size="sm">
<wds-attachment-media><wds-icon name="lucide-file-spreadsheet"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>platforms.csv</wds-attachment-title>
<wds-attachment-description>CSV · 12 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Download platforms.csv" icon="lucide-download"></wds-button>
</wds-attachment-actions>
</wds-attachment>
<wds-attachment size="xs">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>notes.txt</wds-attachment-title>
<wds-attachment-description>TXT · 2 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Remove notes.txt" icon="lucide-x"></wds-button>
</wds-attachment-actions>
</wds-attachment>
</div>
`,
})
export class AttachmentSizesDemo {}Upload states#
idle (dashed border, e.g. an empty drop target), uploading and processing (the title shimmers), error (red; write the reason in the description) and done. Name the buttons by state: cancelling an upload is not removing a file.
import { Component } from '@angular/core';
import { WdsAttachmentActionsComponent, WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent } from '@wds/angular/attachment';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsSpinnerComponent } from '@wds/angular/spinner';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/upload';
import '@wds/core/icons/lucide/x';
import '@wds/core/icons/lucide/circle-alert';
import '@wds/core/icons/lucide/rotate-ccw';
import '@wds/core/icons/lucide/file-text';
@Component({
selector: 'app-attachment-states-demo',
imports: [WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentActionsComponent, WdsIconComponent, WdsSpinnerComponent, WdsButtonComponent],
template: `
<div class="flex w-full max-w-md flex-col gap-2">
<wds-attachment state="idle" class="w-full">
<wds-attachment-media><wds-icon name="lucide-upload"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>Drop a file here</wds-attachment-title>
<wds-attachment-description>PDF or image, up to 10 MB</wds-attachment-description>
</wds-attachment-content>
</wds-attachment>
<wds-attachment state="uploading" class="w-full">
<wds-attachment-media><wds-spinner></wds-spinner></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>delay-report-march.pdf</wds-attachment-title>
<wds-attachment-description>Uploading · 48%</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions><wds-button variant="ghost" size="xs" label="Cancel upload of delay-report-march.pdf" icon="lucide-x"></wds-button></wds-attachment-actions>
</wds-attachment>
<wds-attachment state="processing" class="w-full">
<wds-attachment-media><wds-spinner></wds-spinner></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>passenger-counts.csv</wds-attachment-title>
<wds-attachment-description>Checking the file</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions><wds-button variant="ghost" size="xs" label="Cancel upload of passenger-counts.csv" icon="lucide-x"></wds-button></wds-attachment-actions>
</wds-attachment>
<wds-attachment state="error" class="w-full">
<wds-attachment-media><wds-icon name="lucide-circle-alert"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>crew-roster.xlsx</wds-attachment-title>
<wds-attachment-description>Upload failed: connection lost</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Retry crew-roster.xlsx" icon="lucide-rotate-ccw"></wds-button>
<wds-button variant="ghost" size="xs" label="Remove crew-roster.xlsx" icon="lucide-x"></wds-button>
</wds-attachment-actions>
</wds-attachment>
<wds-attachment state="done" class="w-full">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>timetable-2026.pdf</wds-attachment-title>
<wds-attachment-description>Uploaded · 2.4 MB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions><wds-button variant="ghost" size="xs" label="Remove timetable-2026.pdf" icon="lucide-x"></wds-button></wds-attachment-actions>
</wds-attachment>
</div>
`,
})
export class AttachmentStatesDemo {}Image thumbnails#
orientation="vertical" with wds-attachment-media variant="image". wds-attachment-group scrolls sideways and snaps to each card; wds-attachment-trigger makes a card one button.
import { Component } from '@angular/core';
import { WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentGroupComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent, WdsAttachmentTriggerComponent } from '@wds/angular/attachment';
@Component({
selector: 'app-attachment-images-demo',
imports: [WdsAttachmentGroupComponent, WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentTriggerComponent],
template: `
<wds-attachment-group class="w-full max-w-md">
<wds-attachment orientation="vertical">
<wds-attachment-media variant="image">
<img src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=240&h=240&q=80" alt="" />
</wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>driver.jpg</wds-attachment-title>
<wds-attachment-description>JPG · 480 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-trigger label="Open driver.jpg"></wds-attachment-trigger>
</wds-attachment>
<wds-attachment orientation="vertical">
<wds-attachment-media variant="image">
<img src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=240&h=240&q=80" alt="" />
</wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>conductor.jpg</wds-attachment-title>
<wds-attachment-description>JPG · 480 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-trigger label="Open conductor.jpg"></wds-attachment-trigger>
</wds-attachment>
<wds-attachment orientation="vertical">
<wds-attachment-media variant="image">
<img src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=240&h=240&q=80" alt="" />
</wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>dispatcher.jpg</wds-attachment-title>
<wds-attachment-description>JPG · 480 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-trigger label="Open dispatcher.jpg"></wds-attachment-trigger>
</wds-attachment>
<wds-attachment orientation="vertical">
<wds-attachment-media variant="image">
<img src="https://images.unsplash.com/photo-1517841905240-472988babdf9?w=240&h=240&q=80" alt="" />
</wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>inspector.jpg</wds-attachment-title>
<wds-attachment-description>JPG · 480 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-trigger label="Open inspector.jpg"></wds-attachment-trigger>
</wds-attachment>
</wds-attachment-group>
`,
})
export class AttachmentImagesDemo {}Composer#
xs chips in a group above a text field, each with a remove button.
import { Component } from '@angular/core';
import { WdsAttachmentActionsComponent, WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentGroupComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent } from '@wds/angular/attachment';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsButtonComponent } from '@wds/angular/button';
import { WdsTextareaComponent } from '@wds/angular/textarea';
import '@wds/core/icons/lucide/file-text';
import '@wds/core/icons/lucide/x';
import '@wds/core/icons/lucide/image';
import '@wds/core/icons/lucide/paperclip';
@Component({
selector: 'app-attachment-composer-demo',
imports: [WdsAttachmentGroupComponent, WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentActionsComponent, WdsIconComponent, WdsButtonComponent, WdsTextareaComponent],
template: `
<div class="flex w-full max-w-md flex-col gap-2 rounded-xl border border-border p-2">
<wds-attachment-group>
<wds-attachment size="xs">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>ticket-4821.pdf</wds-attachment-title>
<wds-attachment-description>182 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Remove ticket-4821.pdf" icon="lucide-x"></wds-button>
</wds-attachment-actions>
</wds-attachment>
<wds-attachment size="xs">
<wds-attachment-media><wds-icon name="lucide-image"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>receipt.png</wds-attachment-title>
<wds-attachment-description>96 KB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Remove receipt.png" icon="lucide-x"></wds-button>
</wds-attachment-actions>
</wds-attachment>
<wds-attachment size="xs">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>route-map.pdf</wds-attachment-title>
<wds-attachment-description>1.3 MB</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Remove route-map.pdf" icon="lucide-x"></wds-button>
</wds-attachment-actions>
</wds-attachment>
</wds-attachment-group>
<wds-textarea placeholder="Describe the problem…" aria-label="Message"></wds-textarea>
<div class="flex items-center justify-between">
<wds-button variant="ghost" size="sm" label="Attach a file" icon="lucide-paperclip"></wds-button>
<wds-button size="sm">Send</wds-button>
</div>
</div>
`,
})
export class AttachmentComposerDemo {}Link#
wds-attachment-trigger with href makes the card a link; buttons in wds-attachment-actions stay clickable above it.
import { Component } from '@angular/core';
import { WdsAttachmentActionsComponent, WdsAttachmentComponent, WdsAttachmentContentComponent, WdsAttachmentDescriptionComponent, WdsAttachmentMediaComponent, WdsAttachmentTitleComponent, WdsAttachmentTriggerComponent } from '@wds/angular/attachment';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/file-text';
import '@wds/core/icons/lucide/download';
@Component({
selector: 'app-attachment-link-demo',
imports: [WdsAttachmentComponent, WdsAttachmentMediaComponent, WdsAttachmentContentComponent, WdsAttachmentTitleComponent, WdsAttachmentDescriptionComponent, WdsAttachmentActionsComponent, WdsAttachmentTriggerComponent, WdsIconComponent, WdsButtonComponent],
template: `
<div class="w-full max-w-sm">
<wds-attachment class="w-full">
<wds-attachment-media><wds-icon name="lucide-file-text"></wds-icon></wds-attachment-media>
<wds-attachment-content>
<wds-attachment-title>ticket-4821.pdf</wds-attachment-title>
<wds-attachment-description>PDF · 182 KB · opens in a new tab</wds-attachment-description>
</wds-attachment-content>
<wds-attachment-actions>
<wds-button variant="ghost" size="xs" label="Download ticket-4821.pdf" icon="lucide-download"></wds-button>
</wds-attachment-actions>
<wds-attachment-trigger href="#" target="_blank" label="Open ticket-4821.pdf"></wds-attachment-trigger>
</wds-attachment>
</div>
`,
})
export class AttachmentLinkDemo {}API References#
wds-attachment#
wds-attachment-media (an icon or a thumbnail), wds-attachment-content with a title and
a description, and wds-attachment-actions with buttons. state shows the upload: a dashed border while
idle (e.g. an empty drop target), a shimmering title while uploading or processing, red while error.
wds-attachment-trigger makes the whole card one button or link.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| state | WdsAttachmentState | 'done' | |
| size | WdsAttachmentSize | 'default' | sm or xs (a chip, e.g. in a composer). |
| orientation | WdsAttachmentOrientation | 'horizontal' | vertical: a tile with the media on top (e.g. image thumbnails). |
Slots
| Slot | Description |
|---|---|
| (default) | wds-attachment-media, wds-attachment-content, wds-attachment-actions, wds-attachment-trigger. |
wds-attachment-media#
wds-attachment: a file icon (icon) or a thumbnail (image, the <img> fills it).
In the error state the icon turns red; a thumbnail is dimmed until the upload is done.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| variant | WdsAttachmentMediaVariant | 'icon' | icon on a muted square, or image filling it. |
Slots
| Slot | Description |
|---|---|
| (default) | wds-spinner. |
wds-attachment-content#
wds-attachment: wds-attachment-title and wds-attachment-description.
Slots
| Slot | Description |
|---|---|
| (default) |
wds-attachment-title#
uploading or processing.
Slots
| Slot | Description |
|---|---|
| (default) |
wds-attachment-description#
error state, so put the reason here.
Slots
| Slot | Description |
|---|---|
| (default) |
wds-attachment-actions#
wds-attachment (download, remove, retry), above wds-attachment-trigger. Use
wds-button variant="ghost" size="xs" icon="…" with a label. On a vertical card they sit in its top corner.
Slots
| Slot | Description |
|---|---|
| (default) |
wds-attachment-trigger#
wds-attachment one button (listen to click) or, with href, one link. Give it a label
with the file name; buttons in wds-attachment-actions stay clickable above it.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| label | string | '' | |
| href | string | undefined | ||
| target | string | undefined | ||
| download | string | undefined | download of a link). | |
| pressed | boolean | undefined | aria-pressed), e.g. a selected thumbnail. |
wds-attachment-group#
Slots
| Slot | Description |
|---|---|
| (default) | wds-attachment elements. |
CSS custom properties
| Property | Description |
|---|---|
| --wds-attachment-group-gap |
Accessibility#
Screen reader#
error state put the reason in wds-attachment-description, because the red color is not announced.
wds-attachment-trigger is a native <button> (with pressed: aria-pressed) or, with href, an <a>; give it a label with the file name. Buttons in wds-attachment-actions need a label that names the file, e.g. „Remove report.pdf”.
aria-live="polite" that says how many files are uploaded.
Keyboard support#
| Key | Function |
|---|---|