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
Pill, Outlined & Sizes

Pill shape

NewDoneBlocked

Outlined

ProBeta

Sizes

SmallDefaultLarge
Positioned Badges (Buttons & Icons)
New
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>
  <VdBadge variant="warning" outlined>Beta</VdBadge>
  <VdBadge size="sm">Small</VdBadge>
  <VdBadge size="lg">Large</VdBadge>
</template>

CSS Classes

ClassDescription
.vd-badgeBase badge. Inline-block with padding, rounded corners, and centered text.
.vd-badge-primaryPrimary color background with on-fill ink.
.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.
:sizesm | md | lg (default "md"). Omit the class for md.
:outlinedTransparent background with colored border and text.
default slotBadge content.

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.