Cards
Five card types for different purposes plus a full set of hover effects. Ready-made layouts are in the examples; data tables are covered by a separate page, Tables & Lists.
1. Which card
All four are plain boxes with a border and shadow - what differs is their purpose and what each one adds on top.
| Class | For what | What it adds |
|---|---|---|
.card |
A universal container: a dashboard panel, a form, a modal's content. | Nothing - a plain surface. |
.featured-box |
Presenting a feature or a service on a landing page. | A thick top border and a slot for an icon. |
.thumb-info |
Portfolio, gallery, category tiles. | A background photo and a title overlay that appears on hover. |
.testimonial |
A customer review. | A layout for a quote, a rating, and an author with an avatar. |
.stat-tile |
A KPI tile in a dashboard (revenue, customer count…). | A horizontal icon + number layout, one fixed value size, and an optional trend delta. |
Card content. Header and footer are optional.
Featured box
A thick top border in the accent color.
2. The classic card
Three zones, all optional. A plain .card is
already complete - add a header and footer only when you have
something to put in them.
<div class="card">
<div class="card-header">Title</div>
<div class="card-body">Content…</div>
<div class="card-footer">Actions</div>
</div>
| Class | What it does |
|---|---|
.card |
A --bg-surface surface, a border, rounded
corners, and a shadow. Clips its content, so a
full-width image automatically gets rounded corners
too.
|
.card-header |
A title bar with a separating line. |
.card-body |
The main padded content. Without it, content sticks to the edges - see pitfall #1. |
.card-footer |
A footer for buttons and metadata; a dimmed background. |
A card as a modal's content
Inside <dialog class="modal-dialog">,
it's .card that gives the window its header,
body, and button bar. There are no separate modal classes
for these zones - see
Modals, Tabs & Accordions.
3. Featured box and image cards
Featured box
A card for a single product feature. The icon and the thick top border make it a rhythmically repeatable element - three or four side by side in a grid.
<div class="featured-box">
<div class="featured-box-icon"><svg class="icon" aria-hidden="true"><use href="img/icons-sprite.svg#ph-lightning"></use></svg></div>
<h4>Speed</h4>
<p>Feature description…</p>
</div>
Image cards
A photo with an overlay that slides in on hover.
Requires two levels: .thumb-info
wraps the whole thing and clips the photo, while
.thumb-info-wrapper inside holds the image
itself. Without that second level, there's nothing to scale
on hover.
<a href="#" class="thumb-info">
<span class="thumb-info-wrapper">
<img src="photo.jpg" alt="">
</span>
<span class="thumb-info-title">Project name</span>
</a>
| Class | Component | What it does |
|---|---|---|
.featured-box |
Featured box | A card with an accent border on top. |
.featured-box-icon |
Featured box | A round slot for an icon or emoji. |
.thumb-info |
Image card | The wrapper; clips the photo and holds the overlay. |
.thumb-info-wrapper |
Image card | The layer with the photo - this is what scales on hover. |
.thumb-info-title |
Image card | The caption on the overlay. |
.thumb-info-bottom |
Image card | A variant: caption at the bottom edge. |
.thumb-info-center |
Image card | A variant: caption centered. |
.thumb-info-light |
Image card | A lighter overlay - for dark photos. |
4. Testimonials
A customer review: a quote, a rating, and an author. The
rating is .testimonial-stars, the same mechanism
as .star-rating in the shop - you pass the value
via the --rating variable, not a class.
<div class="testimonial">
<div class="testimonial-stars" style="--rating: 5;"></div>
<p class="testimonial-quote">The rollout went smoother than we expected.</p>
<div class="testimonial-author">
<img class="testimonial-avatar" src="avatar.jpg" alt="">
<div>
<div class="testimonial-name">Anna Kowalska</div>
<div class="testimonial-role">COO</div>
</div>
</div>
</div>
| Class | What it does |
|---|---|
.testimonial |
The review's wrapper. |
.testimonial-stars |
The rating. Driven by the --rating
variable (0-5, fractions partially fill a star).
|
.testimonial-quote |
The quote's content. |
.testimonial-author |
The footer: an avatar plus the person's info. |
.testimonial-avatar |
The author's photo, cropped to a circle. |
.testimonial-name |
The full name. |
.testimonial-role |
The job title or company. |
Several reviews side by side
Drop testimonials into a .carousel and you get
a swipeable slider with no extra code. Details in
Carousels & Lightbox.
5. Stat Tile (KPI card)
A metric tile: an icon with no colored background (tested and
dropped in practice), a label, one fixed value size always, and
an optional trend delta. Pair it with .card -
.stat-tile only adds the internal layout, the rest
(background, border, shadow) comes from the card.
<div class="card stat-tile">
<div class="stat-tile-icon stat-tile-icon-success">
<svg class="icon icon-lg"><use href="img/icons-sprite.svg#ph-credit-card"></use></svg>
</div>
<div class="stat-tile-body">
<span class="stat-tile-label">Net revenue</span>
<span class="stat-tile-value">18,420<span class="stat-tile-unit">USD</span></span>
<span class="stat-tile-delta stat-tile-delta-up">
<svg class="icon"><use href="img/icons-sprite.svg#ph-trend-up"></use></svg>
+12% <span class="stat-tile-delta-context">vs previous period</span>
</span>
</div>
</div>
| Class | What it does |
|---|---|
.stat-tile |
Requires .card on the same element - sets
the horizontal layout (icon + content) and padding.
|
.stat-tile-icon |
Icon with no background. Defaults to
--primary.
|
.stat-tile-icon-success /
-warning /
-danger /
-info
|
Change only the icon's color (the -text
variants, contrastive on a light card background).
|
.stat-tile-label |
The label above the number - truncated with an ellipsis if too long. |
.stat-tile-value |
The number - always the same size, no matter the instance. That's the whole point of this component: consistent hierarchy across a whole row of KPI tiles. |
.stat-tile-unit |
The unit after the number (e.g. "USD", "%") - smaller and muted. |
.stat-tile-delta |
An optional trend indicator. The -up /
-down variants set the color.
|
.stat-tile-delta-context |
The delta's caption (e.g. "vs previous period") in
--text-muted.
|
Why the number has a fixed size
Hand-rolled KPI cards drift in practice - each new one gets a
different text size on the number, until the row of tiles
stops looking like one system.
.stat-tile-value doesn't leave that choice open:
one fixed size, set once in the component.
6. Effects and overlapping onto a hero
Hover
The effects only touch transform and
opacity, so the GPU handles them and they don't
trigger a page layout recalculation. They can be combined on
one element.
| Class | Effect | Needs JS |
|---|---|---|
.hover-spring |
A springy bounce on hover. | no |
.hover-gpu-shadow |
A growing shadow without animating box-shadow.
|
no |
.hover-scale |
Enlargement. Strength set by --hover-scale. |
no |
.hover-shadow |
Lift with a shadow. Height: --hover-y. |
no |
.hover-tilt |
A fixed 3D tilt on hover. | no |
.tilt-card |
A tilt that follows the cursor. Disables itself on touch - saves battery. | yes |
Overlapping the section above
A classic landing-page layout: a card overlapping the bottom
edge of a hero. That's a negative top margin -
.overlap-container gives a default value, and its
variants let you match it to the card's height.
The .overlap-up-* variants only work from
md (768px) up. On a phone they do nothing
and give no sign of it. If the card should overlap the hero on
mobile too, use .overlap-container: it has its own,
smaller value for narrow screens.
| Class | What it does |
|---|---|
.overlap-container |
Pulls the element up. On mobile the offset is smaller, so the card doesn't cover the hero's heading. |
.overlap-up-50 |
Pulls up by about 50px. |
.overlap-up-100 |
Pulls up by about 100px. |
.overlap-up-150 |
Pulls up by about 150px - for tall cards. |
7. Pitfalls
1
Content dropped straight into .card
A plain .card has no padding - that's
deliberate, so a full-width image or table can reach
all the way to the edges. Text dropped in directly,
though, sticks right to the border. Wrap it in
.card-body or add a spacing class to the
card, e.g. .p-4.
<!-- WRONG - text right against the border -->
<div class="card">Content</div>
<!-- RIGHT -->
<div class="card"><div class="card-body">Content</div></div>
<div class="card p-4">Content</div>
2
An image card without .thumb-info-wrapper
An image dropped straight into .thumb-info
displays correctly, so the mistake is easy to miss -
nothing simply happens on hover. It's the
.thumb-info-wrapper layer that scales, not
the <img> itself; without it there's
nothing to animate.
3 A rating concatenated into a class name
It's tempting to generate class="stars-4"
in your template. That name doesn't exist as a literal
in the source, so neither PurgeCSS nor your editor's
search will find it. The rating rides in a variable
precisely so a value from the backend doesn't create
new classes.
<!-- WRONG -->
<div class="testimonial-stars stars-<?= $rating ?>">
<!-- RIGHT -->
<div class="testimonial-stars" style="--rating: <?= $rating ?>;">
4 A card overlapping a hero hides behind it
.overlap-container lifts the element with a
negative margin and gives it a z-index, but
if the hero section has its own stacking context (e.g.
via position and a higher
z-index), the card will end up behind it.
Stick to the scale from the
--z-index-* variables
instead of writing your own numbers.