VDS

Card

Displays a card with an image, title, description, and link.

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

Installation

npx @vds-testing/cli add card
npx @vds-testing/cli add card

Usage

import {
  Card,
  CardBadge,
  CardContent,
  CardDescription,
  CardFooter,
  CardTitle,
} from "@/components/vds/card"
import { Image } from "@/components/vds/image"
<Card>
  <Image src="/images/cards/vale-108-jh.webp" alt="Describe the image" variant="card" />
  <CardContent>
    <CardTitle href="#">Card Title</CardTitle>
    <CardDescription>Card Description</CardDescription>
    <CardFooter href="#">Read more</CardFooter>
  </CardContent>
</Card>

By default the card is 370px wide (capped at its container width) with a light gray border stroke drawn inside the edge. The image fills the card width at the card ratio (370 × 208px by default), and the title sits 16px below it. CardContent is white with 20px horizontal padding. Image assets should be exported at 2x the displayed size as WebP.

Examples

CardFooter is optional. Leave it out when the card doesn’t need a “Read more” link.

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

With badge

Place CardBadge between Image and CardContent to overlay a Badge on the image. It sits flush in the top-right corner of the card by default. position="bottom-left" pins it flush to the bottom-left corner of the image.

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

Custom width and image ratio

Set the card width with a width class, and change the image shape with the ratio prop on Image. The image always fills the card width.

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

Props

Card

Prop Type Default Description
class string - Additional CSS classes. Pass a width class (e.g. w-[280px]) to override the default 370px width

CardTitle

Prop Type Default Description
href string - Makes the title a link with the VDS focus-text focus state
class string - Additional CSS classes

CardDescription, CardContent

Prop Type Default Description
class string - Additional CSS classes

CardFooter

Prop Type Default Description
href string - Link destination
disabled boolean false Marks the link as disabled
class string - Additional CSS classes

CardBadge

Prop Type Default Description
position “top-right” | “bottom-left” “top-right” Corner of the image the badge is pinned to, with no inset
variant, textCase, class - - All Badge props (variant, textCase, class)