---
layout: ~/layouts/MdxDocLayout.astro
title: "Badge"
description: "Displays a small label for status, categorization, or metadata."
sourceFile: "components/badge"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import CodeBlock from "~/components/docs/CodeBlock.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import Heading from "~/components/docs/Heading.astro";
import {
  BadgeVariantsDemo,
  BadgePrimaryDemo,
  BadgeSecondaryDemo,
  BadgeDestructiveDemo,
  BadgeSuccessDemo,
  BadgeOutlineDemo,
  BadgeBetaDemo,
  BadgeInSentenceDemo,
} from "~/components/demos/BadgeDemo";

{/* Hero Demo */}

<ComponentSection>
  <ComponentExample demo="BadgeVariantsDemo">
    <BadgeVariantsDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* Installation */}

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>
  <CodeBlock code={`import { Badge } from "@cloudflare/kumo";`} lang="tsx" />
  <Heading level={3}>Granular</Heading>
  <CodeBlock
    code={`import { Badge } from "@cloudflare/kumo/components/badge";`}
    lang="tsx"
  />
</ComponentSection>

{/* Usage */}

<ComponentSection>
  <Heading level={2}>Usage</Heading>

```tsx
import { Badge } from "@cloudflare/kumo";

export default function Example() {
  return <Badge variant="primary">New</Badge>;
}
```

</ComponentSection>

{/* Examples */}

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Variants</Heading>

<h4 class="mb-3 text-base font-medium">Primary</h4>
<ComponentExample demo="BadgePrimaryDemo">
  <BadgePrimaryDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Secondary</h4>
<ComponentExample demo="BadgeSecondaryDemo">
  <BadgeSecondaryDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Destructive</h4>
<ComponentExample demo="BadgeDestructiveDemo">
  <BadgeDestructiveDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Success</h4>
<ComponentExample demo="BadgeSuccessDemo">
  <BadgeSuccessDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Outline</h4>
<ComponentExample demo="BadgeOutlineDemo">
  <BadgeOutlineDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Beta</h4>
<ComponentExample demo="BadgeBetaDemo">
  <BadgeBetaDemo client:visible />
</ComponentExample>

  <Heading level={3}>In a sentence</Heading>
  <ComponentExample demo="BadgeInSentenceDemo">
    <BadgeInSentenceDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* API Reference */}

<ComponentSection>
  <Heading level={2}>API Reference</Heading>
  <PropsTable component="Badge" />
</ComponentSection>
