Skip to content
Playground

Badge

A compact label with independent appearance and color.

Badge separates appearance from color. Use variant to choose the surface treatment and color to choose a semantic intent or named palette.

defaultoutlinesolidsoft
TSX
import { Badge, type BadgeColor, type BadgeVariant } from "@zentara-co/zenos-ui";
  • default: A tinted surface with a matching border.
  • outline: A transparent surface with a colored outline.
  • solid: A strong fill with a contrasting foreground and a richer dark-mode surface.
  • soft: A low-emphasis fill without a visible border.

Every appearance supports the same colors. Omitting both props gives variant="default" and color="neutral". Neutral default and outline badges use visible gray surfaces and borders instead of low-opacity white or black.

Choose an intent with neutral, brand, danger, warning, information, or success. For categorical distinctions, choose gray, red, orange, yellow, lime, green, teal, cyan, sky, blue, indigo, purple, or pink.

Color and appearance are independent: for example, variant="outline" color="danger" and variant="soft" color="danger" share an intent but have different emphasis. The palettes use mode-aware semantic tokens.

Use rounded for fully rounded corners, or rounded={false} for regular corners. Badge defaults to false. Shape is independent of variant and color, including custom variants. Custom classes can still override the corner radius.

Regular cornersFully rounded

Use Badge.Icon for decorative leading or trailing icons. The wrapper hides its contents from assistive technology so the badge text remains the accessible label. Badge.Root is an alias for Badge.

VerifiedActive

Use render={<a href="…" />} when a label navigates to another page or section. Badge renders that anchor instead of a wrapping span, preserving variant, color, rounded, custom styling, hover feedback, and a visible keyboard focus ring. Without render, Badge and Badge.Root remain noninteractive spans.

Put native anchor props such as href, target, rel, download, and aria-current on the element passed to render. Base UI merges its classes, styles, event handlers, and ref with Badge’s props. Use Badge.Icon for decorative icons inside a link. For a new tab, pair target="_blank" with rel="noopener noreferrer" and make that behavior clear in the link text.

You can also pass your router’s link component through render, provided it forwards props and its ref to the underlying anchor. A render callback is supported when you need to construct the element yourself; spread the supplied props onto that element so styling, accessibility attributes, and refs are preserved.

Like Button, Badge accepts your own appearance through the usual className prop. You do not need to supply variant, color, or variantClassName. Your classes apply last and override conflicting built-in styles while keeping the base layout, icon sizing, and native behavior.

Define the background, border, foreground, shape, and spacing you want to replace, using semantic tokens for theme-aware colors. Layout-only classes keep the default appearance, and native style props remain available. Built-in variant and color props are optional conveniences, not requirements for custom styling.

CampaignReady

The same className approach works with render links. Share a class string or an application CSS class when you want to reuse a custom appearance.

For a compact uppercase category label, use Status Pill.

Badge
Badge.Root
Badge.Link
Badge.Icon

API

PropTypeDefaultDescription
className string — Custom styling and instance overrides. No variant or color prop is required.
render ReactElement | ((props, state) => ReactElement) — Replace the default span with an anchor or router link. Base UI merges props, handlers, and refs.
rounded boolean false Fully rounded corners when true; regular corners when false.
variant BadgeVariant default default, outline, solid, soft, or a consumer-owned appearance name.
variantClassName string — Optional classes for existing named-variant integrations. Use className for custom styling.
color BadgeColor neutral Semantic intent or named color palette, independent of appearance.
native props React.HTMLAttributes<HTMLSpanElement> — Forwards native attributes, events, aria-*, data-*, className, style, and ref.
href string — Navigation destination on the anchor passed to render. Also supported by Badge.Link.
anchor props AnchorHTMLAttributes<HTMLAnchorElement> — Badge.Link forwards native anchor attributes and an HTMLAnchorElement ref.

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

Badge renders a native span by default, not an interactive control or an automatic live region. When using render with a link, supply an href and descriptive link text, and keep its keyboard focus indicator visible. Do not nest interactive elements inside it or use it for actions that belong on a button. Keep text concise and do not rely on color alone to communicate meaning. Use role="status" on a noninteractive label only when the content actually needs a polite live announcement.