Badge

Inline status indicator with color variants.

Example

default success warning danger info

Props

PropTypeDefaultDescription
variant'default' | 'success' | 'warning' | 'danger' | 'info''default'Color variant
classstringAdditional CSS classes
childrenSnippetBadge content

Usage

<script>
  import { Badge } from '@chrissnell/chonky-ui';
</script>

<Badge variant="success">online</Badge>

NotificationBadge

Compact count pill that auto-hides at zero and caps large counts (e.g. 99+). Companion to Badge — use Badge for inline status text, NotificationBadge for unread/pending counts adjacent to an element.

Badge vs NotificationBadge

Side-by-side comparison:

Badge: unread
NotificationBadge: 5

Counts

Count=0 is hidden by default; over-cap counts render as ${cap}+.

count=0 (hidden)
0 count=0, showZero
1 count=1
12 count=12
99+ count=100 (default cap)
99+ count=9999 (default cap)
999+ count=9999, cap=999

Adjacent to a nav link

Typical use case: positioned next to a nav item in a sidebar, indicating unread items for that destination. The badge's fixed small footprint slots neatly against text.

Accessibility

Renders role="status" with an auto-generated aria-label like "5 unread" or "99+ unread". Screen readers announce the label rather than the visible digits, so 99+ reads as "99+ unread". Override via the label prop for different semantics (e.g. "3 in queue", "12 pending approvals").

3 default label ("3 unread")
3 label="3 in queue"
99+ over-cap, custom label

Props

PropTypeDefaultDescription
countnumberRequired. Count to display.
capnumber99Counts above this render as ${cap}+.
showZerobooleanfalseWhen false, count=0 renders nothing.
labelstringOverride the default aria-label.
classstringAdditional CSS classes.

Usage

<script>
  import { NotificationBadge } from '@chrissnell/chonky-ui';
</script>

<!-- Hidden when count is 0 -->
<NotificationBadge count={unreadCount} />

<!-- Always visible, even at zero -->
<NotificationBadge count={unreadCount} showZero />

<!-- Custom cap and aria label -->
<NotificationBadge count={pending} cap={999} label={`${pending} pending approvals`} />