Badge

Material Design 3 badge web component (small dot or large numeric/text badge).

  • 1.1 KB gzipped
  • @lit-material/badge 0.0.3
  • Renders on the server

Example

Install

npm install @lit-material/badge @lit-material/tokens
import "@lit-material/badge";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-badge>

Material Design 3 badge โ€” a small status indicator, typically overlaid on a corner of another element (an icon, an avatar, a nav item) to flag a notification count or unread state.

Properties

PropertyAttributeTypeDefaultDescription
valuevalueBadgeValue | undefinednoneA number (clamped by max) or arbitrary text. Unset renders the small dot.
maxmaxnumber99Above this, a numeric value displays as "{max}+" instead of the exact number.
labellabelstring | undefinednoneAccessible name for a standalone badge. See the class docs for when to use this.

CSS parts

PartDescription
badgeThe badge's visible surface.

Source on GitHub npm