GitHub 560+

Badge

Displays a badge or a component that looks like a badge.

Badge Secondary Destructive Outline Ghost Link
Verified 8 99 20+

Installation

npx shadcn@latest add @fulldev/badge

Usage

import { Badge } from "@/components/ui/badge"
<Badge variant="default">Badge</Badge>

Use the polymorphic as prop to render the badge as a link element.

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

<Badge as="a" href="/">Badge</Badge>

Polymorphic

Badge is strict polymorphic. Pass as to change the rendered element and use attributes for that element.

<Badge as="button" type="button">Action</Badge>
<Badge as="a" href="/docs/">Docs</Badge>

Notes

  • Use variants first before adding custom classes.
  • Badge works well for status labels, counts, and small inline metadata.

API Reference

See the GitHub source code for more information on props.