Skip to content

Badge

A small status descriptor for labeling or counting items. Badges appear next to notifications, avatars, or icons to indicate a status, value, or special attribute.

Installation

bash
npx @zizigy/capsule add Badge

Usage

Basic Badge

html
<capsule-badge>Badge</capsule-badge>

Variants

html
<capsule-badge>1</capsule-badge>
<capsule-badge variant="outline">12</capsule-badge>
<capsule-badge variant="ghost">New</capsule-badge>
<capsule-badge variant="dot">!</capsule-badge>

Value and Max

You can use value and max attributes on capsule-badge to show numbers. If value exceeds max, badge shows max+:

html
<!-- Just value -->
<capsule-badge value="10">10</capsule-badge>
<!-- If value > max, shows max+ -->
<capsule-badge
  value="150"
  max="99"
  >99+</capsule-badge
>
<!-- 99+ -->

Sizes

html
<capsule-badge size="sm">sm</capsule-badge>
<capsule-badge>md</capsule-badge>
<capsule-badge size="lg">lg</capsule-badge>

Color

html
<capsule-badge color="primary">primary</capsule-badge>
<capsule-badge color="success">success</capsule-badge>
<capsule-badge color="danger">danger</capsule-badge>
<capsule-badge color="warning">warning</capsule-badge>

Attributes

AttributeTypeDefaultDescription
variantstring-Badge style variant
sizestring-Badge size
valuestring/number0Value shown in the badge
maxstring/number-If set, caps the value; shows max+ if exceeded
typestring-Type attribute for buttons
colorstring-Badge color (e.g. 'primary', 'success', 'danger', HEX, RGB, etc.)

Variant Values

  • outline - Outlined badge
  • ghost - Ghost badge
  • dot - Small dot (can contain text or icon)

Accessibility

  • ✅ Keyboard interaction support
  • ✅ ARIA attributes for screen readers

Released under the MIT License.