Skip to content

Badge ​

A small status label with default, secondary, outline and destructive variants.

Installation ​

bash
npx bootcn add badge
bash
pnpm dlx bootcn add badge
bash
yarn dlx bootcn add badge
bash
bunx --bun bootcn add badge

The CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.

Usage ​

html
<span class="badge bootcn-badge bootcn-badge--default">Default</span>
<span class="badge bootcn-badge bootcn-badge--secondary">Secondary</span>
<span class="badge bootcn-badge bootcn-badge--outline">Outline</span>
<span class="badge bootcn-badge bootcn-badge--destructive">Destructive</span>

Variants ​

  • bootcn-badge--default — primary emphasis (default).
  • bootcn-badge--secondary — neutral.
  • bootcn-badge--outline — transparent with a border.
  • bootcn-badge--destructive — danger emphasis.

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css (shared design tokens).

No JavaScript.

Accessibility ​

  • Badges are decorative or supplementary; the text inside is read inline. If a badge conveys state that is not otherwise described, include that information in the surrounding text or on the related control.
  • Colors use Bootstrap's subtle/emphasis tokens, which have sufficient contrast in light and dark mode.
  • Motion is disabled when the user prefers reduced motion.

Source ​

The exact files the CLI installs (badge@1.1.0). View on GitHub · Report an issue

html
<div class="d-flex flex-wrap gap-2 align-items-center">
  <span class="badge bootcn-badge bootcn-badge--default">Default</span>
  <span class="badge bootcn-badge bootcn-badge--secondary">Secondary</span>
  <span class="badge bootcn-badge bootcn-badge--outline">Outline</span>
  <span class="badge bootcn-badge bootcn-badge--destructive">Destructive</span>
</div>
css
/* Tailwind-like badge: rounded-md, text-xs, font-semibold. */
.bootcn-badge {
  --bootcn-badge-bg: var(--bootcn-primary);
  --bootcn-badge-fg: var(--bootcn-primary-foreground);
  --bootcn-badge-border: transparent;

  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: var(--bootcn-badge-padding-y) var(--bootcn-badge-padding-x);
  border: var(--bootcn-border-width) solid var(--bootcn-badge-border);
  border-radius: var(--bootcn-radius);
  background-color: var(--bootcn-badge-bg);
  color: var(--bootcn-badge-fg);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1rem;
  white-space: nowrap;
  transition:
    background-color var(--bootcn-transition),
    color var(--bootcn-transition),
    border-color var(--bootcn-transition);
}

.bootcn-badge--default {
  --bootcn-badge-bg: var(--bootcn-primary);
  --bootcn-badge-fg: var(--bootcn-primary-foreground);
}

.bootcn-badge--secondary {
  --bootcn-badge-bg: var(--bootcn-secondary);
  --bootcn-badge-fg: var(--bootcn-secondary-foreground);
}

.bootcn-badge--outline {
  --bootcn-badge-bg: transparent;
  --bootcn-badge-fg: var(--bootcn-foreground);
  --bootcn-badge-border: var(--bootcn-border-color);
}

.bootcn-badge--destructive {
  --bootcn-badge-bg: var(--bootcn-destructive);
  --bootcn-badge-fg: var(--bootcn-destructive-foreground);
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.