Expandable Gallery
ComponentsExpandable Gallery
SectionsNew

Expandable Gallery

Image panels that expand on selection, with stacked cards on small screens.

USE IT FORArchitecture portfoliosDestination galleriesSelected project collections
React + CSS
Explore the full-width experienceOpen preview
Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/expandable-gallery.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { ExpandableGallery } from '@/components/anticraft/ExpandableGallery';

export function Example() {
  return (
    <ExpandableGallery
      title="Selected projects"
      items={[
        { id: 'hearth', title: 'Hearth House', meta: 'Residential architecture', src: '/images/hearth.jpg', alt: 'A concrete house above the coast', href: '/projects/hearth' },
        { id: 'headland', title: 'Headland Retreat', meta: 'Coastal hospitality', src: '/images/headland.jpg', alt: 'A timber retreat overlooking the ocean', imagePosition: '70% 50%', href: '/projects/headland' },
        { id: 'terrace', title: 'The Living Edge', meta: 'Interiors', src: '/images/terrace.jpg', alt: 'A shaded terrace beside an open living space', href: '/projects/terrace' },
      ]}
    />
  );
}
03

Props

PropTypeDefaultDescription
itemsExpandableGalleryItem[]RequiredImages with a unique id, title, src and alt. Optional meta, imagePosition, href and linkLabel fields add supporting details and a separate destination link. Supply your own image files and real destination URLs. An empty list shows an empty state.
titlestring'Selected projects'Heading above the panels. Pass an empty string to omit it; the section keeps an accessible name.
defaultValuestringFirst itemThe initially selected image id. Missing or removed selections fall back to the first available item.
onValueChange(id: string) => voidundefinedCalled when a visitor selects a different image. Pass callbacks from a client component.
classNamestring''Additional classes. Customize --ac-expandable-ink, --ac-expandable-muted, --ac-expandable-line, --ac-expandable-radius and --ac-expandable-height. Panels stack below a component width of 580px.
item.hrefstringundefinedOptional native link shown in the selected panel. It is separate from the selection button. The demo opens the original image file; installed galleries follow your supplied destination.
04

Motion & accessibility

Considered by default.

Click, tap, Enter or Space to expand a panel. Arrow keys move and select adjacent panels; Home and End select the first or last. Every selection button remains in the Tab order. Narrow containers stack all panels without hiding their images or names. Reduced motion removes panel, image and link transitions.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.