Skip to Content
Neshel-UI
Components

Badge

Small status and category labels using the semantic colour roles.

Server-compatible (no "use client")

Purpose

Badge labels a status or category with a short text. It renders a non-interactive <span>.

Import

import.tsx
import { Badge } from "@neshel-ui/components";

Usage

Preview: badge-variants
Preview theme
defaultsecondaryoutlinesuccesswarningdestructiveaccentSmall
badge-variants.tsx
import { Badge } from "@neshel-ui/components";
import { Inline } from "@neshel-ui/layout";

const variants = [
  "default",
  "secondary",
  "outline",
  "success",
  "warning",
  "destructive",
  "accent",
] as const;

export default function BadgeVariants() {
  return (
    <Inline space="2" align="center" wrap>
      {variants.map((variant) => (
        <Badge key={variant} variant={variant}>
          {variant}
        </Badge>
      ))}
      <Badge size="sm" variant="success">
        Small
      </Badge>
    </Inline>
  );
}

API

BadgeProps

BadgeProps
PropTypeDefaultDescription
refRef<HTMLSpanElement>——
sizeBadgeSize"md"Size (default "md").
variantBadgeVariant"default"Colour role (default "default").

Also accepts the props of: React DOM attributes.

BadgeVariant

type BadgeVariant = (typeof badgeColorVariants)[number] | "outline"

BadgeSize

type BadgeSize = "sm" | "md"

Accessibility

A Badge has no role and is read as text in context. Do not rely on colour alone: the text itself must say "Failed", "Active", etc. For a changing status, announce it with a live region.

Styling

success, warning, destructive and accent use the corresponding colour roles (with their paired foregrounds), so custom themes keep contrast.

Common mistakes

  • Making badges interactive: use a Button with size="sm" instead.
Edit on GitHub

On this page