Skip to content

Card

The .card class creates a visually distinct container with background, border-radius, and shadow styling. It can be applied to any block-level element.

Basic Usage

live preview
editable html
<div class="card">
  <hgroup>
    <h2>Card title</h2>
    <p>This is the subtitle</p>
  </hgroup>
  <p>This is the main content of the card.</p>
</div>

Cards support <header> and <footer> child elements with distinct background styling.

live preview
editable html
<div class="card">
  <header>
    <h2>Card title</h2>
  </header>
  <p>Cards support optional header and footer sections that are visually distinct from the main content.</p>
  <footer>
    <button class="secondary">Cancel</button>
    <button>Confirm</button>
  </footer>
</div>

Using with Different Elements

The .card class works on any semantic element. Choose the element that best matches your content's meaning:

live preview
editable html
<!-- On article element (recommended for semantic content) -->
<article class="card">
  <p>Self-contained composition like a blog post or widget.</p>
</article>

<!-- On div element (for purely presentational containers) -->
<div class="card">
  <p>A generic container with card styling.</p>
</div>

<!-- On section element (for thematic grouping) -->
<section class="card">
  <p>Thematic grouping of content.</p>
</section>

Variants

Intent Variants

To convey intent and importance, cards can be styled with different variants:

live preview
See code

Modifiers

.subtle creates cards with a more muted appearance, often used for less prominent actions.

live preview
See code

.ghost creates transparent background cards with colored text and borders, useful for secondary actions where you want minimal visual weight.

live preview
See code