GooseUI

Components

Badge


Badge shows a short label or status next to other content. It is a server component and works without JavaScript. It has soft state variants, icons, a status dot, three sizes, a link form, a removable tag and a round counter.

Preview

PublishedLivePendingNew

Installation

npx shadcn@latest add @gooseui/badge
pnpm dlx shadcn@latest add @gooseui/badge
yarn dlx shadcn@latest add @gooseui/badge
bunx --bun shadcn@latest add @gooseui/badge

Usage

import { Badge } from "@/components/ui/badge"

<Badge variant="success">Published</Badge>

Examples

States

Soft background, same-hue text and a thin border.

defaultsecondaryoutlinedestructivesuccesswarninginfoneutral
<Badge variant="default">default</Badge>
<Badge variant="secondary">secondary</Badge>
<Badge variant="outline">outline</Badge>
<Badge variant="destructive">destructive</Badge>
<Badge variant="success">success</Badge>
<Badge variant="warning">warning</Badge>
<Badge variant="info">info</Badge>
<Badge variant="neutral">neutral</Badge>

With an icon

An svg child gets the right size and spacing. Put it on either side.

PublishedPending4.9+12%Read the docs
import { ArrowUp, Check, Star, TriangleAlert } from "lucide-react"

<Badge variant="success"><Check />Published</Badge>
<Badge variant="warning"><TriangleAlert />Pending</Badge>
<Badge variant="secondary"><Star />4.9</Badge>
<Badge variant="success"><ArrowUp />+12%</Badge>
<Badge variant="outline">Read the docs<ArrowUp className="rotate-45" /></Badge>

Status dot

The dot takes the text color. pulse adds a ring that stops under reduced motion.

OnlineLivePendingNeutralInfo
<Badge variant="success" dot>Online</Badge>
<Badge variant="destructive" dot="pulse">Live</Badge>
<Badge variant="warning" dot>Pending</Badge>

Sizes

SmallDefaultLarge
<Badge size="sm" variant="info">Small</Badge>
<Badge variant="info">Default</Badge>
<Badge size="lg" variant="info">Large</Badge>

Link badge

asChild gives the badge styles to a link or a button and adds hover and focus.

<Badge asChild variant="info">
  <a href="/docs">Read the docs</a>
</Badge>

<Badge asChild variant="outline">
  <button type="button"><Star />Star</button>
</Badge>

Removable tags

BadgeRemove is a plain button. Handle removal in your own client component.

ReactTypeScriptTailwindNext.js
"use client"

import { useState } from "react"
import { Badge, BadgeRemove } from "@/components/ui/badge"

export function TagFilters() {
  const [tags, setTags] = useState(["React", "TypeScript", "Tailwind"])
  return tags.map((tag) => (
    <Badge key={tag} variant="secondary" size="lg">
      {tag}
      <BadgeRemove
        aria-label={`Remove ${tag}`}
        onClick={() => setTags((p) => p.filter((x) => x !== tag))}
      />
    </Badge>
  ))
}

Counter

BadgeCount is a round counter. Position it over an icon or a button.

399+
import { Bell } from "lucide-react"
import { BadgeCount } from "@/components/ui/badge"

<span className="relative inline-flex">
  <Button variant="outline" size="icon" aria-label="Notifications">
    <Bell />
  </Button>
  <BadgeCount count={128} className="absolute -top-2 -right-2" />
</span>

Status in a card and a table

Invoices
Payment status for the last orders
OrderStatus
#1042Paid
#1043Pending
#1044Cancelled
<Card>
  <CardHeader><CardTitle>Invoices</CardTitle></CardHeader>
  <CardContent>
    <table>
      <tr><td>#1042</td><td><Badge variant="success" dot>Paid</Badge></td></tr>
      <tr><td>#1043</td><td><Badge variant="warning" dot>Pending</Badge></td></tr>
      <tr><td>#1044</td><td><Badge variant="destructive" dot>Cancelled</Badge></td></tr>
    </table>
  </CardContent>
</Card>

Props

PropTypeDefaultDescription
variantstringdefaultVisual style: default, secondary, outline, destructive, success, warning, info, neutral, beta, draft, experimental.
size"sm" | "default" | "lg"defaultSize of the badge.
dotboolean | "pulse"falseStatus dot before the text. pulse adds a pulsing ring.
asChildbooleanfalseRender the only child (a, button) with badge styles. The dot is not added in this mode.
classNamestring-Extra CSS classes.
BadgeRemove aria-labelstringRemoveAccessible label of the cross button.
BadgeCount countnumber-Number to show. Above max it renders as max+.
BadgeCount maxnumber99Upper limit before the plus sign.