Aperto

Thumbnails that open into a full image or video in place, and close back into the thumbnail they came from.

@patternmode/aperto

Reference

States and variants

The panel takes its shape from each item's width and height, or 3:2 when they're missing.

  • 3:2 when unset

    no width, height
  • Square panel

    width: 1, height: 1
  • Video with a poster

    type: "video", poster
  • Drag down to dismiss

    dismissible={{ threshold, velocity }}
  • Focus comes back here

    after closing
  • Your own image component

    renderImage

Install and use

Pass the media once to the group. Each thumbnail only needs its index.

npm i @patternmode/aperto motion lucide-react
import { Aperto, type ApertoMediaItem } from "@patternmode/aperto";
import "@patternmode/aperto/styles.css";

const media: ApertoMediaItem[] = [
  { id: "photo", type: "image", src: "/photo.jpg", alt: "Photo" },
];

export function MediaGroupExample() {
  return (
    <Aperto.Group media={media} dismissible={{ threshold: 120, velocity: 600 }}>
      {media.map((item, index) => (
        <Aperto.Thumbnail key={item.id ?? item.src} index={index} />
      ))}
    </Aperto.Group>
  );
}

Core API

Aperto.Group

Media Group with keyboard Media Navigation and shared-element transitions.

media*
ApertoMediaItem[]Array of Image Media Items or Video Media Items.
motion
"snappy" | "smooth" | "bouncy""smooth"Media Transition easing preset.
navigationMotion
"float" | "glide" | "snap""glide"Expanded-media navigation transition style.
dismissible
boolean | { threshold?: number; velocity?: number }trueDrag Dismissal behavior for Expanded Media.
classNames
ApertoClassNamesSlot class overrides for Thumbnails and Aperto Controls.
renderImage
RenderImageReplaces Aperto's framework-agnostic img renderer. Next.js consumers can return next/image Image here.

Aperto.Thumbnail

Thumbnail for a Media Item inside a Media Group.

index*
numberPosition in the Media Group.
children
ReactNodeOptional custom thumbnail content.

Read the package README for primitive composition, media renderers, and motion presets.

Keyboard and accessibility

Open, move between items and close without a pointer.

Enter, Space
Open the focused thumbnail. Each one is a button named “Open” and the item’s title.
ArrowLeft, ArrowRight
Move to the previous or next item while open.
Escape
Closes, and focus returns to the thumbnail that opened it.

Package

Package
@patternmode/aperto
Version
3.0.6
Needs
react, react-dom, lucide-react, motion
Licence
MIT