--- title: Badge description: A badge or a component that looks like a badge. --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/badge ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Import the following variables into your CSS file ```css @theme inline { --color-destructive-foreground: var(--destructive-foreground); --color-info: var(--info); --color-info-foreground: var(--info-foreground); --color-success: var(--success); --color-success-foreground: var(--success-foreground); --color-warning: var(--warning); --color-warning-foreground: var(--warning-foreground); } :root { --destructive-foreground: var(--color-red-700); --info: var(--color-blue-500); --info-foreground: var(--color-blue-700); --success: var(--color-emerald-500); --success-foreground: var(--color-emerald-700); --warning: var(--color-amber-500); --warning-foreground: var(--color-amber-700); } .dark { --destructive-foreground: var(--color-red-400); --info: var(--color-blue-500); --info-foreground: var(--color-blue-400); --success: var(--color-emerald-500); --success-foreground: var(--color-emerald-400); --warning: var(--color-amber-500); --warning-foreground: var(--color-amber-400); } ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Badge } from "@/components/ui/badge" ``` ```tsx Badge ``` ## Link You can use the [`render`](https://base-ui.com/react/utils/use-render#migrating-from-radix-ui) prop to make another component look like a badge. Here's an example of a link that looks like a badge. ```tsx import Link from "next/link" import { Badge } from "@/components/ui/badge" export function LinkAsBadge() { return }>New } ``` ## API Reference This is a custom component using Base UI's `useRender` hook, not a direct Base UI wrapper. ### Badge A badge component with variant and size options. | Prop | Type | Default | Description | | --------- | ------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------ | | `variant` | `"default" \| "destructive" \| "error" \| "info" \| "outline" \| "secondary" \| "success" \| "warning"` | `"default"` | Controls the badge styling and color scheme | | `size` | `"default" \| "sm" \| "lg"` | `"default"` | Controls the badge size | | `render` | `React.ReactElement` | - | Render as a different element (e.g., Link) | ## Examples ### Outline ### Secondary ### Destructive ### Info ### Success ### Warning ### Error ### Small ### Large ### With Icon ### With Link ### With Count