Create

General

Badge

Copy page View as Markdown Open in ChatGPT Open in Claude

Displays a badge or a component that looks like a badge.

Usage#

app.component.ts
import { WdsBadgeComponent } from '@wds/angular/badge';

Examples#

Default#

Badge Secondary Destructive Outline Ghost

With icon#

Verified Bookmark

With href the badge renders a native <a>. target="_blank" adds rel="noopener noreferrer" unless you set rel.

Open link Link variant

Custom colors#

--wds-badge-bg, --wds-badge-fg and --wds-badge-border override the colors of the variant.

Blue Green Sky Purple Red

API References#

wds-badge#

A badge, e.g. a status label. With href it renders a native <a>.

Attributes

AttributeTypeDefaultDescription
variantWdsBadgeVariant'default'Visual variant.
hrefstring | undefinedLink URL. Without it the badge is a plain <span>.
targetstring | undefinedLink target, e.g. _blank.
relstring | undefinedLink rel. With target="_blank" it defaults to noopener noreferrer.

Slots

SlotDescription
(default)Content (text, <svg> icon).

CSS parts (::part)

PartDescription
badgeThe inner <span> or <a>.

CSS custom properties

PropertyDescription
--wds-badge-bgCustom background (overrides the variant).
--wds-badge-fgCustom text color (overrides the variant).
--wds-badge-borderCustom border color (overrides the variant).

Accessibility#

Screen reader#

wds-badge renders a <span> with its content as text, or with href a native <a> with the link role.

A badge is not announced as a status: when it shows a change that users need to hear about, put the text in a live region. Give icons aria-hidden="true".

Keyboard support#

KeyFunction
TabMoves focus to a badge with href. A badge without href is not focusable.
EnterFollows the link.
Footer