# Badge

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

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="badge-demo">
  <BadgeDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/badge.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="badge" title="badge.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

## Usage [#usage]

```tsx
import { Badge } from "@/components/ui/badge/badge";
```

```tsx
<Badge variant="outline">Badge</Badge>
```

## Examples [#examples]

### Variants [#variants]

Use the `variant` prop to change the badge style: `default`, `secondary`,
`destructive`, or `outline`.

<ComponentPreview name="badge-demo">
  <BadgeDemo />
</ComponentPreview>

### With Icon [#with-icon]

Add an icon before the label.

<ComponentPreview name="badge-with-icon">
  <BadgeWithIcon />
</ComponentPreview>



### With Spinner [#with-spinner]

Add a `Spinner` to indicate a loading or in-progress state.

<ComponentPreview name="badge-spinner">
  <BadgeWithSpinner />
</ComponentPreview>

### Link [#link]

Wrap the badge in an anchor to make it a link.

<ComponentPreview name="badge-link">
  <BadgeLink />
</ComponentPreview>

### Custom Colors [#custom-colors]

Use utility classes to apply custom colors to the badge.

<ComponentPreview name="badge-colors">
  <BadgeCustomColors />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="badge-rtl" direction="rtl">
  <BadgeRtl />
</ComponentPreview>

## API Reference [#api-reference]

### Badge [#badge]

The `Badge` component displays a badge or a component that looks like a badge.

| Prop        | Type                                                     | Default     |
| ----------- | -------------------------------------------------------- | ----------- |
| `variant`   | `"default" \| "secondary" \| "destructive" \| "outline"` | `"default"` |
| `className` | `string`                                                 | -           |
