Badge Examples
The examples below assume that you have imported the component and set up the theme.
Basic
Show a count of unread items on a button. count sets the number in the badge, and label is the text that assistive technology reads after the button.
The controls switch the badge between a count, a dot, and text, and move it to any of the nine placements.
The pulse and the hide animation will not play for you because your system is set to reduce motion.
<div class="badge-basic"> <sv-badge count="5" label="New notifications"> <button type="button" class="btn" aria-label="Notifications"> <!-- Bell --> <svg fill="currentColor" height="1.25em" viewBox="0 0 24 24" width="1.25em"> <path d="M4,19V17H6V10Q6,7.93 7.25,6.31T10.5,4.2V3.5q0-0.63 0.44-1.06T12,2t1.06,0.44T13.5,3.5V4.2q2,0.5 3.25,2.11T18,10v7h2v2H4Zm8-7.5ZM12,22q-0.82,0-1.41-0.59T10,20h4q0,0.82-0.59,1.41T12,22ZM8,17h8V10q0-1.65-1.17-2.82T12,6T9.18,7.18T8,10v7Z" /> </svg> </button> </sv-badge></div>
<style> .badge-basic { display: grid; place-items: center;
.btn { aspect-ratio: 1; padding: 0.5em; line-height: normal; border-radius: 50%; } }</style>Standalone
Show a status dot next to text, with no element to pin it to. An sv-badge with no children renders the badge inline, and variant="success" colors it.
The dot has no label because the visible text already says the status.
The controls switch the badge between a dot, a count, and text, and change its color and size.
The pulse will not play for you because your system is set to reduce motion.
<p class="badge-standalone"> <sv-badge variant="success"></sv-badge> Online</p>
<style> .badge-standalone { display: flex; gap: 0.5em; align-items: center; justify-content: center; margin: 0; }</style>