Skip to content

Block 288 of 297

Card Carousel

Story or program cards you can drag and flick with momentum, snapping card to card, with arrows and a progress rule.

Puck key
CardCarouselBlock
Export
cardCarouselBlock
React component
<CardCarousel />
Files
components/puck/card-carousel-block.tsx
components/puck/card-carousel.client.tsx
Dependencies
gsap
License
MIT (GSAP has its own license)

About this block

When to use it, how to write for it, and what to change in the code.

What it's for

A row of story or program cards with portrait images that visitors drag or flick, snapping card to card, with arrows and a progress rule below. About one and a quarter cards show on phones, two on tablets and three on desktop. Without JavaScript it is a native swipeable row.

  • Recent stories or blog posts on a home page
  • A program catalog teaser that links to detail pages
  • Volunteer, donor or alumni profiles
Writing the content
  • Cards allows 1 to 12. Use portrait images at 4:5; a card with no Image URL becomes a text-only panel.
  • Fill Image description for every meaningful photo, and leave it blank only for decorative ones.
  • Keep Excerpt to one or two sentences so card heights stay close.
  • Link text beside the heading, such as "All stories", points readers to the full archive and hides when blank.
Accessibility
  • The row is a labelled carousel region, each card is a group announced as "2 of 6", and card titles sit one heading level below the section heading.
  • Arrow keys, Home and End move the row, the arrow buttons are 44px, and a polite live region announces which cards are in view (WCAG 2.1.1).
  • Off-screen cards are made inert so keyboard focus can't land on a hidden card, and reduced motion removes the glide and momentum.
Customizing the code
  • Requires the gsap package (Draggable and InertiaPlugin) and card-carousel.client.tsx. Card widths are basis-4/5 sm:basis-5/12 lg:basis-3/10 on each slide.
  • The snap glide is duration 0.9 with expo.out in go(); throwResistance: 1800 sets how far a flick travels.

Editor fields

What content editors see in the P1 sidebar when they select this block.

  • Eyebrowtext
  • Headingtext
  • Heading levelselect
  • Introtextarea
  • Link texttext
  • Linktext
  • Cardsarray