Card Grid

Responsive card layouts using layout-grid and layout-card. Automatically adapts to screen width without media queries.

Overview

This pattern creates a responsive grid of cards that automatically adjusts column count based on available space. It combines <layout-grid> for the responsive container with <layout-card> for consistent card structure.

Key features:

  • Auto-fit columns based on minimum width
  • No media queries required
  • Multiple card variants (default, outlined, elevated, ghost)
  • Built-in spacing with data-layout-gap
  • Semantic structure with <layout-stack> inside cards

Live Example

A grid of cards with different variants and content structures. Resize your browser to see the responsive behavior.

Source Code

The complete snippet with all card variants. Copy and customize for your content.

Grid Configuration

The <layout-grid> element accepts these data attributes:

Attribute Values Description
data-layout-min CSS length (e.g. 250px, 20ch) Minimum column width. Columns auto-fit based on this value.
data-layout-gap xs s m l xl Gap between grid items using size tokens.

Card Variants

Default Card

Standard card with subtle background and border.

Outlined Card

Transparent background with visible border. Good for text-only cards.

Clickable Card

Make the entire card clickable by wrapping its content in an anchor with class="card-link". No special attribute needed — the .card-link pattern handles the clickable area.

Usage Notes

  • Images: Always include width, height, and loading="lazy" attributes for performance
  • Accessibility: Use descriptive alt text for images; decorative images should have alt=""
  • Links: Place the primary link on the heading. For fully clickable cards, wrap content in an anchor with class="card-link"
  • Structure: Use <layout-stack> inside cards for consistent vertical spacing
  • Metadata: Use <layout-cluster> for horizontal badge/date groupings

Related

Layout Grid

Responsive grid layout element

Layout Card

Card container element

Layout Stack

Vertical stacking element