Skip to content

Components

CountBadge

Inbox137 unread messages

Component reference

Properties

Use CountBadge

A compact count with an optional cap or unread dot.

Example import style
count-badge.tsxTSX
"use client";

import { FloodRoot, CountBadge, Inline, Text } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <Inline gap="2"><Text size="compact">Inbox</Text><CountBadge count={137} formatLabel={count => `${count} unread messages`} /></Inline>
    </FloodRoot>
  );
}

Design notes

  • Use CountBadge for a passive count beside the destination or label it qualifies. It adds no focus stop. Use formatLabel for a localized accessible description.
  • The default visual cap is 99. Counts above max display the cap with a plus sign while assistive technology receives the exact count. Use locale to format the digits.
  • Zero is hidden by default. Set showZero when an explicit zero is useful. Dot presentation signals a nonzero count in tight spaces and always hides zero.
  • Use NavigationItem compactBadge to put an unread dot on a compact navigation control without moving its icon.

API reference

PropValuesDefault
size"sm" | "md" | "lg""sm"
tone"neutral" | "accent" | "error" | "warning" | "success" | "info"—
variant"subtle" | "outline"—
countnumberRequired
maxnumber99
showZerobooleanfalse
presentation"count" | "dot""count"
localestring—
formatLabel(count: number) => string—
Native HTML propsOmit<HTMLAttributes<HTMLSpanElement>, "children">Forwarded
View TypeScript source