CSS Expanding Details Card
A card that smoothly grows to reveal extra text and a link on hover or focus, animating height with grid rows.
Edge functions
Run code close to your users.
Deploy in seconds to hundreds of locations, with no servers to manage.
Read the docs<article class="more-card">
<h3>Edge functions</h3>
<p>Run code close to your users.</p>
<div class="more-card-extra">
<div>
<p>Deploy in seconds to hundreds of locations, with no servers to manage.</p>
<a href="#">Read the docs</a>
</div>
</div>
</article>
.more-card {
width: 230px;
padding: 18px 20px;
border-radius: 16px;
background: #fff;
box-shadow: 0 4px 16px -6px rgba(76, 29, 149, 0.25);
color: #2e1065;
font-family: system-ui, sans-serif;
}
.more-card h3 {
margin: 0;
font-size: 17px;
}
.more-card p {
margin: 4px 0 0;
color: #6d5c91;
font-size: 14px;
line-height: 1.5;
}
.more-card-extra {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.35s ease;
}
.more-card-extra > div {
overflow: hidden;
}
.more-card:hover .more-card-extra,
.more-card:focus-within .more-card-extra {
grid-template-rows: 1fr;
}
.more-card-extra p {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #ede9fe;
}
.more-card a {
display: inline-block;
margin: 8px 0 2px;
color: #7c3aed;
font-size: 14px;
font-weight: 700;
}
.more-card a:focus-visible {
outline: 2px solid #7c3aed;
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.more-card-extra {
transition: none;
}
}
About this CSS Expanding Details Card
This CSS Expanding Details Card is 61 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses transitions, box shadows, CSS Grid and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#fff#2e1065#6d5c91#ede9fe#7c3aed
How to use this expanding details card
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.more-cardclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.