Badges

Small inline status indicators, counters, and labels. Badges scale with their parent font size and support contextual color variants, pill shapes, and three size tiers.

Contextual Variants
DefaultPrimarySecondarySuccessWarningDangerInfoLightDark
<!-- Default (secondary color) -->
<span class="vd-badge">Default</span>

<span class="vd-badge vd-badge-primary">Primary</span>
<span class="vd-badge vd-badge-secondary">Secondary</span>
<span class="vd-badge vd-badge-success">Success</span>
<span class="vd-badge vd-badge-warning">Warning</span>
<span class="vd-badge vd-badge-danger">Danger</span>
<span class="vd-badge vd-badge-info">Info</span>
<span class="vd-badge vd-badge-light">Light</span>
<span class="vd-badge vd-badge-dark">Dark</span>
Pill, Outlined & Sizes

Pill shape

NewDoneBlocked

Outlined

ProBeta

Sizes

SmallDefaultLarge
<!-- Pill badges (fully rounded) -->
<span class="vd-badge vd-badge-pill vd-badge-primary">New</span>

<!-- Outlined badges -->
<span class="vd-badge vd-badge-outlined vd-badge-primary">Pro</span>

<!-- Sizes -->
<span class="vd-badge vd-badge-sm vd-badge-primary">Small</span>
<span class="vd-badge vd-badge-lg vd-badge-primary">Large</span>
Positioned Badges (Buttons & Icons)
New
<!-- Badge on a button -->
<button class="vd-btn vd-btn-primary" style="position:relative;">
  Notifications
  <span class="vd-badge vd-badge-danger"
        style="position:absolute; top:-6px; right:-6px;">3</span>
</button>

<!-- Badge on an icon button -->
<button class="vd-btn vd-btn-icon vd-btn-secondary" style="position:relative;">
  <i class="ph ph-envelope"></i>
  <span class="vd-badge vd-badge-pill vd-badge-primary"
        style="position:absolute; top:-4px; right:-4px;">12</span>
</button>
API Reference

Usage

<script setup lang="ts">
import { VdBadge } from "@vanduo-oss/vd3";
</script>

<template>
  <VdBadge>Primary</VdBadge>            <!-- default variant is primary -->
  <VdBadge variant="success">Done</VdBadge>
  <VdBadge variant="danger" pill>Blocked</VdBadge>
</template>

CSS Classes

ClassDescription
.vd-badgeBase badge. Inline-block with padding, rounded corners, and centered text.
.vd-badge-primaryPrimary color background with white text.
.vd-badge-secondarySecondary (teal/green) background.
.vd-badge-successGreen success background.
.vd-badge-warningAmber warning background.
.vd-badge-dangerRed danger background — the unified status name (matches Vue variant="danger").
.vd-badge-errorRetained backward-compatible alias for .vd-badge-danger.
.vd-badge-infoCyan info background.
.vd-badge-lightLight gray background (inverted in dark mode).
.vd-badge-darkDark gray background with light text.
.vd-badge-pillFully rounded pill shape (border-radius: 50rem).
.vd-badge-outlinedTransparent background with colored border and text.
.vd-badge-smCompact size (font-size: 0.65em).
.vd-badge-lgLarge size (font-size: 0.875em).

Component API (Vue 3)

Prop / slotDescription
:variantprimary | secondary | success | warning | danger | info (default "primary"). The bare .vd-badge class is neutral/secondary, but the VdBadge component defaults to primary.
:pillFully-rounded pill shape.
default slotBadge content.
(size / outline)CSS-only classes (.vd-badge-sm / -lg / -outlined) that ship in vd3's CSS — not wrapped as VdBadge props.

CSS Variables

VariableDefault
--vd-badge-padding-y0.25em
--vd-badge-padding-x0.4em (ratio ~phi)
--vd-badge-padding-y-sm0.15em
--vd-badge-padding-x-sm0.25em (ratio ~phi)
--vd-badge-padding-y-lg0.35em
--vd-badge-padding-x-lg0.55em (ratio ~phi)
--vd-badge-font-size0.75em
--vd-badge-font-weightvar(--vd-font-weight-semibold)
--vd-badge-border-radiusvar(--vd-btn-border-radius-sm)
--vd-badge-pill-border-radius50rem
Accessibility
  • Badges are inline elements; ensure they are placed inside a parent with sufficient text context.
  • For counter badges (e.g., "3" on a notification bell), wrap the parent button in an aria-label that includes the count: aria-label="Notifications, 3 unread".
  • All badge color combinations meet WCAG contrast requirements against both light and dark backgrounds.
  • Avoid using badges alone to convey critical status — pair with text or tooltips.