Badge

<wa-badge> Stable Since 2.0

Badges draw attention to adjacent content by displaying a status, count, or label. Use them to highlight notifications, categorize items, or flag new activity.

Badge

Examples

Link to This Section

Variants

Link to This Section

Set the variant attribute to change the badge's variant.

Brand Success Neutral Warning Danger

Appearance

Link to This Section

Use the appearance attribute to change the badge's visual appearance.

Accent Filled-Outlined Filled Outlined
Accent Filled-Outlined Filled Outlined
Accent Filled-Outlined Filled Outlined
Accent Filled-Outlined Filled Outlined
Accent Filled-Outlined Filled Outlined

Size

Link to This Section

Badges are sized relative to the current font size. You can set font-size on any badge (or an ancestor element) to change it.

Brand Brand Brand Brand Brand

Pill Badges

Link to This Section

Use the pill attribute to give badges rounded edges.

Brand Success Neutral Warning Danger

Drawing Attention

Link to This Section

Use the attention attribute to draw attention to the badge with a subtle animation. Supported effects are bounce, pulse and none.

1 1 1 1 1
1 1 1 1 1

Start & End Decorations

Link to This Section

Use the start and end slots to add presentational elements like <wa-icon> alongside the badge's label.

Start End Both

With Buttons

Link to This Section

One of the most common use cases for badges is attaching them to buttons. To make this easier, badges will be automatically positioned at the top-right when they're a child of a button.

Requests 30 Warnings 8 Errors 6

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/badge/badge.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/badge/badge.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/badge/badge.js';

To import this component for React 18 or below, use the following code:

import WaBadge from '@awesome.me/webawesome/dist/react/badge/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

CSS parts

Link to This Section

Learn more about CSS parts.

Need a hand? Report a bug Ask for help
    No results