VDS

Badge

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

DefaultTealDark tealYellowRed

Installation

npx @vds-testing/cli add badge
npx @vds-testing/cli add badge
pnpm install @vds-testing/react @vds-testing/styles
pnpm install @vds-testing/elements @vds-testing/styles

Packages are consumed via the workspace locally and are not published yet. See Installation for CSS setup.

Usage

Astro:

import { Badge } from "@/components/vds/badge"
<Badge variant="teal">New</Badge>

React:

import { Badge } from "@vds-testing/react"
<Badge variant="teal">New</Badge>

Web Components:

<script type="module">
  import "@vds-testing/elements";
</script>
<vds-badge variant="teal">New</vds-badge>

Examples

Text case

Labels are all caps by default. Set textCase="title" to capitalise the first letter of each word instead.

New todaynew today

In a card

Use CardBadge to overlay a badge on the card image. It sits top-right by default. Set position="bottom-left" to align it with the title instead. See Card for both positions.

Two visitors admiring the plants along a path inside a Vale glasshouseNew
The dinosaur tree that’s still with us
Read more

Variants

Variant Background token Label
default Peach --color-peach Black
teal Teal --color-brand (teal-500) White
yellow Yellow --color-yellow Black
dark-teal Dark teal --color-teal-700 White
red Red --color-destructive White

All variants are solid fills with no border or outline.

Anatomy

  • Badge / vds-badge renders one inline <span>, so it is valid inside paragraphs, headings, links and card content

Props

Badge

Prop Type Default Description
variant “default” | “teal” | “dark-teal” | “yellow” | “red” “default” Background colour
textCase “upper” | “title” “upper” Label casing
class / className string - Additional CSS classes

Web Components use the variant and text-case attributes on vds-badge.