Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Expanding Strips Accordion Gallery Block for React

Five picture strips in a framed row where one is wide and the rest are slivers, each a button that opens it and reveals a solid caption, with arrow keys; rows that grow in height on a phone.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

An expanding-strips gallery for React with Base UI, for Ghyllwick, a walking club. A start-aligned compact header sits over a framed figure with five picture strips side by side: one is wide and the other four are slivers, and the widths trade places in a flex-grow transition. Each strip is a button with aria-expanded; clicking it, or pressing an arrow key from the strip beside it, opens it and closes the one that was open, so exactly one strip is ever open. The open strip carries a solid caption panel with the walk's title, place, year, distance and a sentence, revealed with a clip-path; a closed strip shows only a solid label chip, so text never sits straight over a picture. The row keeps one height whichever strip is open. Below the medium breakpoint the strips are rows that grow in height instead. The pictures are drawn, not photographed: a mountain range, a lake, a forest, a coast and a night sky in your theme's own greys. It's built from Guides, with CSS transitions that stop under reduced motion. The club, the walks and the places are made up for the example.

FAQ

How do I use my own photographs?

Each entry in WALKS has a title, a place, a year, a distance, a label for the closed strip, a blurb and a scene. Add your image's address and replace the Scene in the strip with <img alt="" className="size-full object-cover" src={…} />; the button already has a name for screen readers. The picture is cropped to the strip as an object-cover image is, so it shows more of itself as the strip widens. The comment above Scene says where.

How does it work with a keyboard?

Every strip is a button, so Tab reaches each one and Enter or Space opens it. Left and Right (mirrored in a right-to-left layout) and Up and Down move to the next or previous strip and open it, with focus following; Home and End go to the first and last. The strips are in one list, so a screen reader hears "Round the lake, Harrowmere, 2025, button, expanded".

Why is the caption in a panel and not over the picture?

Text laid straight over a picture can fall below a readable contrast anywhere the picture is light. The caption is a solid panel in your page background, clipped away with clip-path: inset() while the strip is closed and out of the tab order and the accessibility tree (inert and aria-hidden), so a closed strip's text is never read. The label chip on a closed strip is solid for the same reason.

Why doesn't a strip open on hover?

Strips change width under the pointer, which makes a hover trigger flicker where two strips meet. It opens on a click or tap and on a key, which also works on touch screens, where there is no hover.

How does it fit on a phone?

The strips become five rows in a fixed-height stack: the open row is tall and the others are slim bars with their number and name. Opening a row grows it in height while the others shrink, so the block never changes height. The long sentence is hidden on a phone; the title, place, year and distance stay.

Does it respect reduced motion?

Yes. The grow transition and the caption reveal are CSS and turn off under prefers-reduced-motion; the strips then change at once. Nothing moves by itself.

  • Pro

    Featured Hero Gallery

    Masonry and mosaic

    A boat-charter gallery on one hairline grid: a featured picture two cells wide and tall beside four small ones, and choosing a small picture swaps it with the featured one in place.

  • Pro

    Spotlight Ring Gallery

    Carousels and slides

    A watch reseller's gallery: eight round dials stand in a ring around one large dial, and choosing a dial, by pointer or with the arrow keys that turn round the ring, brings it to the centre.

  • Pro

    Coverflow Gallery

    Carousels and slides

    Eight drawn album sleeves in a framed stage with the middle one full size and square and its neighbours turned away and dimmed, moved by buttons, arrow keys or a click, with the title band that closes the frame.

  • Pro

    Hexagonal Honeycomb Gallery

    Masonry and mosaic

    Nineteen hexagonal pictures in an offset honeycomb inside a framed figure, moved across with the arrow keys, the current tile enlarged and named in a live caption.

  • Pro

    A photo essay of five framed pictures in alternating rows, with a Short and Full switch: Short shows each title, Full adds the place, date, credit and a two-sentence story.

  • Pro

    A features section for a dashboard builder: six panels side by side in one rounded frame, five folded to a strip with a sideways label and one open to a headline, a sentence and a small drawing.