Skip to Content

Badge

A brandless inline badge element. Unlike native form elements, <span> carries no browser UA styles — the base .badge class ships with neutral gray fallbacks so it renders as a recognizable badge without any modifier class applied.

Demo

New

Usage

import { Badge } from '@froglet/ui' <Badge>New</Badge> // Themed <Badge className="badge--brand">New</Badge>

Props

PropTypeDescription
childrenReactNodeBadge text or content.
classNamestringAdditional CSS classes. Use to apply a token block.
refReact.Ref<HTMLSpanElement>Forwarded to the underlying <span>.
...propsHTMLAttributes<HTMLSpanElement>All standard span attributes.

CSS Custom Properties

TokenDefaultDescription
--badge-background-color#e5e7ebBackground fill.
--badge-text-color#374151Text color.
--badge-border-radius9999pxCorner rounding (pill shape).
--badge-padding0.125rem 0.5remInner spacing.
--badge-font-familyinheritFont family.
--badge-font-sizeinheritFont size.
--badge-font-weightinheritFont weight.
--badge-line-heightinheritLine height.
--badge-border-width0Border width. Set to 1px to enable an outline badge.
--badge-border-stylesolidBorder style.
--badge-border-colorBorder color. Only visible when --badge-border-width is set.

Accessibility

  • <span> has no implicit ARIA role. For a live-region notification badge (e.g. an unread count), add role="status" and aria-live="polite".
  • Ensure text contrast meets WCAG AA when choosing background and text token values.
Last updated on