Expandable Accordion Cards with Image
A stack of feature cards, each expanding on click to reveal its description and a preview image. The open/close animation drives an actual CSS grid-template-rows transition between 0fr and 1fr rather than toggling display, so the content genuinely grows and shrinks. Only one card is expanded at a time.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its media-slot dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/expandable-accordion-cards-image.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/feature/feature100.tsx instead.
Usage
The file also exports feature100Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Feature100, feature100Demo } from "@/components/blocks/feature/feature100"; export default function Page() { return <Feature100 {...feature100Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| eyebrow | string | undefined | Small label above the heading; omitted entirely when unset. |
| heading | ReactNode | none | Section heading. |
| description | string | undefined | Supporting copy under the heading. |
| items | AccordionCardItem[] | none | Card entries; the first is expanded by default. |
| className | string | undefined | Extra classes for the outer section element. |
Types
type AccordionCardItem = { title: string; description: string; image: { src: string; alt: string }; };
Behavior notes
- Real client-side state: clicking a card's header toggles it via useState<number | null>; opening a card closes whichever was previously open, and clicking the already-open card's header closes it, so at most one card is expanded at a time.
- "use client" component, so its demo props live in the sibling feature100.demo.tsx file per this repo's client/demo-file-split rule, not in feature100.tsx itself.
- The expand/collapse animation is a real CSS transition on `grid-template-rows` (0fr closed, 1fr open) applied via an inline style keyed off the open state, combined with `overflow-hidden` on the inner wrapper, rather than a display toggle or a fixed max-height hack.
- The first card is expanded, revealing its description and image, by default on mount.
- aria-expanded and aria-controls wire each card header to its panel for screen readers.
More Feature Blocks
View all →Full-Bleed Workspace Band
Two-column header above a full-bleed image band with a live view switcher, closing on three numbered captions.
Center-Line Journey Timeline
Vertical hairline timeline alternating stages either side, dropping a phone frame on one step.
Figure-Led Evidence Rows
Tall image with a floating before-and-after card, leading into oversized-figure evidence rows.
Staircase Asset Trio
Three image tiles stepping down the page in a staircase, each floating a different live asset.
Sticky Reference List
Sticky heading column beside three labelled groups of checked capabilities, closing on a footnote.
Day Timeline Rows
Hairline rows walking through one working day, stamped with time and a live approval card inline.