Create

General

Attachment

Copy page View as Markdown Open in ChatGPT Open in Claude

A file card with an icon or thumbnail, a name, details and actions, with upload states.

Usage#

app.component.ts
import { WDS_ATTACHMENT } from '@wds/angular/attachment';

Examples#

Default#

An icon, the name and details, and a download button in wds-attachment-actions.

timetable-2026.pdf PDF · 2.4 MB

Sizes#

Default, sm and xs (a chip, e.g. in a message composer).

station-report.pdf PDF · 1.1 MB platforms.csv CSV · 12 KB notes.txt TXT · 2 KB

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.

Drop a file here PDF or image, up to 10 MB delay-report-march.pdf Uploading · 48% passenger-counts.csv Checking the file crew-roster.xlsx Upload failed: connection lost timetable-2026.pdf Uploaded · 2.4 MB

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.

driver.jpg JPG · 480 KB conductor.jpg JPG · 480 KB dispatcher.jpg JPG · 480 KB inspector.jpg JPG · 480 KB

Composer#

xs chips in a group above a text field, each with a remove button.

ticket-4821.pdf 182 KB receipt.png 96 KB route-map.pdf 1.3 MB
Send

wds-attachment-trigger with href makes the card a link; buttons in wds-attachment-actions stay clickable above it.

ticket-4821.pdf PDF · 182 KB · opens in a new tab

API References#

wds-attachment#

A file card: 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

AttributeTypeDefaultDescription
stateWdsAttachmentState'done'Upload state.
sizeWdsAttachmentSize'default'Card size: default, sm or xs (a chip, e.g. in a composer).
orientationWdsAttachmentOrientation'horizontal'vertical: a tile with the media on top (e.g. image thumbnails).

Slots

SlotDescription
(default)wds-attachment-media, wds-attachment-content, wds-attachment-actions, wds-attachment-trigger.

wds-attachment-media#

Square at the start of 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

AttributeTypeDefaultDescription
variantWdsAttachmentMediaVariant'icon'icon on a muted square, or image filling it.

Slots

SlotDescription
(default)An icon, an image or a wds-spinner.

wds-attachment-content#

Text part of wds-attachment: wds-attachment-title and wds-attachment-description.

Slots

SlotDescription
(default)Title and description.

wds-attachment-title#

File name, cut with an ellipsis. Shimmers while the card is uploading or processing.

Slots

SlotDescription
(default)The name.

wds-attachment-description#

Line under the title: type, size or upload progress. Red in the error state, so put the reason here.

Slots

SlotDescription
(default)The description.

wds-attachment-actions#

Buttons of 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

SlotDescription
(default)Buttons.

wds-attachment-trigger#

Makes the whole 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

AttributeTypeDefaultDescription
labelstring''Accessible name, e.g. „Open report.pdf”.
hrefstring | undefinedMakes the card a link.
targetstring | undefinedLink target.
downloadstring | undefinedSaves the link target as a file with this name (download of a link).
pressedboolean | undefinedToggle button state (aria-pressed), e.g. a selected thumbnail.

wds-attachment-group#

A row of attachments that scrolls sideways and snaps to each card, with faded edges where more cards are hidden.

Slots

SlotDescription
(default)wds-attachment elements.

CSS custom properties

PropertyDescription
--wds-attachment-group-gapSpace between the cards (default 12px).

Accessibility#

Screen reader#

A card has no role: the title and description are read as text. In the 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”.

Announce upload progress outside the cards, e.g. a line with aria-live="polite" that says how many files are uploaded.

Keyboard support#

KeyFunction
TabMoves focus to the card trigger and the action buttons.
EnterSpaceActivates the focused trigger or button.
Footer