TuMarca

Badge

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

stable
Tipo: ui
Versión: 1.0.0
data-display badge label tag status

Comparación entre la versión Astro (Saastro) y React (shadcn/ui)

🚀 saastro/ui (Astro)
Badge
⚛️ shadcn/ui (React)

Installation

Usage

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

<Badge>Badge</Badge>

Examples

Default

<Badge>Default</Badge>

Secondary

<Badge variant="secondary">Secondary</Badge>

Destructive

<Badge variant="destructive">Destructive</Badge>

Outline

<Badge variant="outline">Outline</Badge>

Use an anchor tag for clickable badges.

<a href="/docs">
  <Badge>Documentation</Badge>
</a>

With Icon

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

<Badge>
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
  Premium
</Badge>

Props

PropTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline""default"The visual style of the badge
classstring-Additional CSS classes

Accessibility

  • Badges are decorative by default and use <span> element
  • When used as links, ensure the parent <a> has proper focus states
  • Consider adding aria-label for icon-only badges