Hero Ui

Badge

Component 4

About

Displays a small indicator positioned relative to another element, commonly used for notification counts, status dots, and labels.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Badge to your project and fits it to your theme.

Code

How Badge is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { Badge } from "@/components/ui/heroui-badge";

const AVATAR_URL = "https://cdn.21st.dev/assets/mirror/c4/c48cdbaa2058ca5420edd44e17537d7f2cbaab72f5ae01e5738fa82f3d090ba1.jpg";
const PLACEMENTS = ["top-right", "top-left", "bottom-right", "bottom-left"] as const;

function Avatar() {
  return (
    <span className="inline-flex size-10 shrink-0 overflow-hidden rounded-3xl bg-zinc-100 dark:bg-zinc-800">
      <img className="size-full object-cover" src={AVATAR_URL} alt="" />
    </span>
  );
}

export default function BadgePlacementsDemo() {
  return (
    <div className="flex min-h-screen w-full items-center justify-center overflow-hidden bg-background p-8">
      <div className="flex items-center gap-8">
        {PLACEMENTS.map((placement) => (
          <div className="flex flex-col items-center gap-2" key={placement}>
            <Badge.Anchor>
              <Avatar />
              <Badge color="accent" placement={placement} />
            </Badge.Anchor>
            <span className="text-xs text-muted-foreground">{placement}</span>
          </div>
        ))}
      </div>
    </div>
  );
}

export { BadgePlacementsDemo };

More by Hero Ui

View all
  • DatePicker

    DatePicker

    465
  • Chip

    Chip

    440
  •  The Pagination

    The Pagination

    361
  • HeroUI Color Picker

    HeroUI Color Picker

    105
  • Skeleton

    Skeleton

    104
  • HeroUI Table

    HeroUI Table

    100
  • HeroUI Disclosure Group

    HeroUI Disclosure Group

    94
  • HeroUI AlertDialog

    HeroUI AlertDialog

    80