pnpm dlx @glinui/cli@latest add badge#482 opened by Priya Nair
#479 opened by Diego Alvarez
#471 opened by Hana Sato
Installation
pnpm dlx @glinui/cli@latest add badgePrefer the package?
Usage
Variants
Every vocabulary variant on the default tone. Omit variant to follow the ambient design style.
import { Badge } from "@glinui/ui"
export function BadgeVariantsDemo() { return ( <div className="flex flex-wrap items-center gap-3"> <Badge variant="glinr">glinr</Badge> <Badge variant="solid">solid</Badge> <Badge variant="plain">plain</Badge> <Badge variant="soft">soft</Badge> <Badge variant="outline">outline</Badge> <Badge variant="ghost">ghost</Badge> <Badge variant="gradient">gradient</Badge> </div> )}Sizes, dots and icons
Sizes, status dots and leading icons.
import { Lock, ShieldCheck } from "@phosphor-icons/react"import { Badge } from "@glinui/ui"
export function Demo() { return ( <div className="flex w-full max-w-xl flex-col gap-5"> <div className="flex flex-wrap items-center gap-2"> <Badge size="sm">Small</Badge> <Badge size="md">Medium</Badge> <Badge size="lg">Large</Badge> <Badge tone="accent" variant="solid">New</Badge> <Badge tone="danger" variant="outline">Blocked</Badge> </div> <div className="flex flex-wrap items-center gap-2"> <Badge variant="soft" tone="success" dot>Live</Badge> <Badge variant="soft" tone="warning" dot dotTone="accent">Pending</Badge> <Badge variant="soft" tone="danger" dot dotTone="live">Failed</Badge> <Badge variant="soft" tone="info"> <ShieldCheck aria-hidden className="mr-1 size-3.5" /> Verified </Badge> <Badge variant="outline"> <Lock aria-hidden className="mr-1 size-3.5" /> Private </Badge> </div> </div> )}Variants
import { Badge } from "@glinui/ui"
export function BadgeVariantDemo() {
return (
<div className="flex flex-wrap gap-2">
<Badge>Default</Badge>
<Badge variant="glass">Glass</Badge>
<Badge variant="outline">Outline</Badge>
<Badge variant="ghost">Ghost</Badge>
</div>
)
}Sizes
import { Badge } from "@glinui/ui"
export function BadgeSizeDemo() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge size="sm">Small</Badge>
<Badge size="md">Medium</Badge>
<Badge size="lg">Large</Badge>
</div>
)
}Raised badge with status dot
raised uses the lift ring. dot adds a glowing status dot, asChild renders a link.
import { Badge } from "@glinui/ui"
export function Demo() {
return (
<div className="flex flex-wrap gap-2">
<Badge variant="raised" dot dotTone="ok">All systems normal</Badge>
<Badge variant="raised" dot dotTone="live" asChild>
<a href="/changelog">What is new</a>
</Badge>
</div>
)
}Accessibility
- Renders as `<span>` -- decorative by default.
- Add `role="status"` if badge conveys live state.
- Use badge text that remains understandable out of context.
- Do not rely on color-only meaning.
ARIA Attributes
- Decorative by default
- Add `role="status"` for live state badges
Reduced Motion
No animation dependencies.
Badge is static and motion-independent.
API Reference
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | SurfaceVariant | ExtraVariant | "default" | "primary" | "secondary" | "destructive" | "success" | "warning" | "info" | "raised" | "frosted" | No | ambient (glinr) | Surface variant. Omit to follow the ambient design style (glinr by default, plain for minimal, glass for glass). |
tone | SurfaceTone | No | neutral | Colour tone for the vocabulary variants. |
size | "sm" | "md" | "lg" | No | md | Height scale (h-5/h-6/h-7). |
asChild | boolean | No | false | Render the child element (for example an anchor) with badge styling. |
dot | boolean | No | false | Show a glowing status dot before the content. |
dotTone | BadgeDotTone | No | "ok" | Dot color. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { Badge } from "@glinui/ui"Source Files
Dependencies
@glinui/uiGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/badge.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
BadgeProps
BadgeProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
asChild | boolean | No | false | Render the child element (for example an anchor) with badge styling. |
dot | boolean | No | false | Show a glowing status dot before the content. |
dotTone | BadgeDotTone | No | "ok" | Dot color. |
size | "sm" | "md" | "lg" | No | - | - |
tone | SurfaceTone | No | - | Colour tone for the vocabulary variants. |
variant | SurfaceVariant | ExtraVariant | "default" | "primary" | "secondary" | "destructive" | "success" | "warning" | "info" | "raised" | "frosted" | No | - | Visual variant. Omit for the ambient design style (glinr by default). Vocabulary: glinr, solid, plain, soft, outline, ghost, gradient, glass. Legacy names (default, primary, secondary, destructive, success, warning, info, raised, frosted) still work; liquid, matte and glow stay badge-specific. |