CSC Design System v4.0.1
VueFlavour Vue React Angular TypeScript
Flavour Vue React Angular TypeScript
PrimaryCSC UI Colors Primary Secondary AccentCustom Colors Red Orange Green Blue Purple Pink
CSC UI Colors Primary Secondary AccentCustom Colors Red Orange Green Blue Purple Pink
Guides Getting started Customization Data visualization Migration guide Componentsc-accordionc-alertc-autocompletec-badgec-breadcrumbc-buttonc-button-groupc-cardc-checkboxc-color-pickerc-csc-logoc-data-tablec-date-pickerc-dividerc-file-uploadc-iconc-icon-buttonc-linkc-listc-loaderc-login-buttonsc-login-cardc-mainc-menuc-messagec-modalc-navigation-buttonc-number-fieldc-otp-inputc-pagec-paginationc-popoverc-progress-barc-progress-circlec-radio-groupc-selectc-side-navigationc-sliderc-spinnerc-statusc-stepsc-switchc-tablec-tabsc-tagsc-text-fieldc-time-pickerc-toastsc-toolbarc-tooltipc-tree-select

<c-badge>

A small pill that pins a short count or label to the top-right corner of the element it sits in, such as the number of unread messages on a button.

Usage

Put the c-badge inside the element it annotates, with the count in the default slot. The badge is absolutely positioned, so that element must be a positioning context: inside c-button and c-icon-button it already is; anywhere else, give the container position: relative.

<c-button>
  Messages
  <c-badge>2</c-badge>
</c-button>

When to use

  • A count or short marker on another element: unread messages, pending approvals, new items.
  • On a c-icon-button, set its badge prop instead of slotting a badge; a c-tag likewise takes its count in its own badge prop.
  • For a word naming the state of a record (Active, Expired), use c-status.

Appearance

The badge fills with the warning role and its on-warning ink, and a 2px ring in the surface colour sets it off from whatever it overlaps. It is 16px tall and grows with its text, so keep the content to a few characters. It ignores the pointer: clicks pass through to the element beneath.

Accessibility

The badge has no role: its text is read as part of whatever contains it. Inside a button it joins the button's accessible name ("Messages 2"), so check that the combination makes sense, or set an aria-label on the button that states the count in words ("Messages, 2 unread"). A changed count is not announced.

Customization

::part(root) is the pill. Recolour it with semantic tokens so it follows the theme mode:

c-badge.done::part(root) {
  background-color: var(--c-success);
  color: var(--c-on-success);
}

Examples

Basic
Vue React Angular TypeScript
<template>
  <div class="example-row">
    <span style="position: relative">
      <c-icon :path="mdiBellOutline" size="32" />

      <c-badge>3</c-badge>
    </span>

    <c-icon-button appearance="outlined" aria-label="Messages, 1 unread">
      <c-icon :path="mdiEmailOutline" />

      <c-badge class="success-badge">1</c-badge>
    </c-icon-button>

    <c-button>
      Default
      <c-badge>2</c-badge>
    </c-button>
  </div>
</template>

<script setup lang="ts">
import { mdiBellOutline, mdiEmailOutline } from '@mdi/js';
</script>

<style>
c-badge.success-badge::part(root) {
  background-color: var(--c-success);
  color: var(--c-on-success);
}
</style>

API reference

<c-badge>

A small pill that pins a short count or label to the top-right corner of the element it sits in, such as the number of unread messages on a button.

Slots

SlotDescription
defaultThe badge content, typically a short count or label

CSS parts

Style from outside with c-badge::part(name) — parts are the library's only styling customization API.

PartDescription
rootThe badge pill itself, absolutely positioned at the top right corner of its parent