Create

General

Alert

Copy page View as Markdown Open in ChatGPT Open in Claude

Displays a callout for user attention.

Usage#

app.component.ts
import { WdsAlertComponent } from '@wds/angular/alert';

Examples#

Default#

Destructive#

variant="destructive" uses the error color and adds a default icon.

Action#

The action slot places a control on the right, vertically centered. With an action the alert gets role="status".

Enable

Custom colors#

Background and text color are set on the host, so a class or a style on the element changes them. The border is on the base part: set its color with ::part(base) or with --wds-alert-border-color.

API References#

wds-alert#

A callout for user attention: icon, title, description and an optional action on the right, vertically centered. The ARIA role is set automatically: status with an action, alert otherwise. A role attribute set on the element takes precedence. Background and text color are on the host, so a class or a style on the element changes them; the border color is --wds-alert-border-color.

Attributes

AttributeTypeDefaultDescription
variantWdsAlertVariant'default'Variant: destructive uses the error color and adds an icon.
headingstring''Title. The title slot takes precedence.
descriptionstring''Description. The element content takes precedence.

Slots

SlotDescription
(default)Description (instead of description), e.g. with links or paragraphs.
iconIcon (SVG, 16px). The destructive variant has a default icon.
titleTitle (instead of heading).
actionAction on the right, vertically centered (e.g. wds-button size="xs").

CSS parts (::part)

PartDescription
baseThe box with the padding and the border.
iconThe icon container.
titleThe title.
descriptionThe description.
actionThe action container.

CSS custom properties

PropertyDescription
--wds-alert-border-colorBorder color (default --wds-border).
--wds-alert-description-colorDescription color (default --wds-muted-foreground, the error color in destructive).

Accessibility#

Screen reader#

wds-alert sets its own role: alert by default, so screen readers announce it when it appears, and status when the action slot is filled. A role you set on the element takes precedence.

The title and description are plain text, not a heading. The default icon of the destructive variant is hidden from screen readers; give your own icon in the icon slot aria-hidden="true".

Keyboard support#

The alert has no keyboard interaction of its own. Controls in the action slot and links in the description follow the page tab sequence.

Footer