Components
Badge
Small status and category labels using the semantic colour roles.
Server-compatible (no "use client")
import.tsx
badge-variants.tsx
Edit on GitHubPurpose
Badge labels a status or category with a short text. It renders a non-interactive <span>.
Import
import { Badge } from "@neshel-ui/components";Usage
Preview: badge-variants
defaultsecondaryoutlinesuccesswarningdestructiveaccentSmall
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
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLSpanElement> | — | — |
| size | BadgeSize | "md" | Size (default "md"). |
| variant | BadgeVariant | "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
Buttonwithsize="sm"instead.