VisorVisor
ComponentsForm

Photo Picker

A grid of photo thumbnails, one chosen, with a staggered draw wave each time it opens.

Default

Each thumbnail is a button with aria-pressed; the chosen one wears a 2px ring and every image grows a little on hover. The thumbnails rise in a quick wave from the top left when the grid mounts and every time play changes. Here a counter replays it.

dusk

In a Popover

The picker is only the grid, so it sits in whatever popover or panel you bring. Pass the open state to play so the wave replays on every open, and to load so no thumbnail is fetched before the first open. Once loaded, thumbnails stay loaded.

In Five Looks

The grid takes its colours and corners from the theme: the resting ring is the theme's border, the chosen ring its key colour (--interactive-primary-bg), and the thumbnails take the theme's corner shape. It draws no surface of its own, so over a photo it sits in a glass panel or popover (see Glass). Here it is in each look on the theme picked in the docs; the Photo looks turn glass on over a photo.

Today
Dark
Dark + Photo
Light
Light + Photo

Honcho Backstage

Backstage's Photo menu grid from the theme alone: squircle thumbnails and the pink key ring on the chosen one. Today is the honcho theme; the other four looks are honcho-backstage. Over a photo the grid sits on a glass panel.

Today
Dark
Dark + Photo
Light
Light + Photo

Installation

npx visor add photo-picker

This copies two files into your project:

  • components/ui/photo-picker/photo-picker.tsx — the component
  • components/ui/photo-picker/photo-picker.module.css — the styles

Usage

import { PhotoPicker } from '@/components/ui/photo-picker/photo-picker';

const photos = [
  { key: 'dusk', thumb: '/photos/dusk-480.webp', label: 'Dusk at the stage' },
  { key: 'lake', thumb: '/photos/lake-480.webp' },
];

<PhotoPicker aria-label="Pick Your Background" photos={photos} value={photo} onValueChange={setPhoto} play={open} load={open} />

Theming

VariableDefaultSets
--photo-picker-columns5Columns above 760px
--photo-picker-columns-narrow3Columns at 760px and under
--photo-picker-gap--spacing-2 (8px)Gap between thumbnails
--photo-picker-padding--spacing-1 (4px)Room for the chosen ring inside the scroll box
--photo-picker-max-heightmin(62vh, 560px)Height before the grid scrolls
--photo-picker-radius--radius-xlThumbnail corner radius
--photo-picker-ring--border-defaultThe 1px inset ring before a thumbnail loads
--photo-picker-ring-selected--interactive-primary-bgThe chosen thumbnail's 2px ring
--photo-picker-ease--motion-easing-enterThe wave's and the hover's easing
--photo-picker-draw-duration320ms (--motion-duration-enter, else --motion-duration-800, × 0.4)Each thumbnail's rise
--photo-picker-draw-gap48msThe beat between neighbours
--photo-picker-draw-rise10pxHow far each thumbnail rises

Thumbnails are 4:3 and scale to 1.08 on hover. For anything else, target the buttons through your own className.

API Reference

PhotoPickerProps

PropTypeDefaultDescription
photos{ key: string; thumb: string; label?: string }[]—The photos, in order. label is the thumbnail's accessible name; it defaults to "Photo N".
valuestring | nullnullThe chosen photo's key.
onValueChange(key: string) => void—Called with a photo's key when it is pressed.
playboolean | number—The draw wave plays on mount and every time play changes, except to false. Pass the menu's open state, or a counter you bump.
loadbooleantrueThumbnails load only once this has been true, and stay loaded after. Pass the menu's open state to wait for the first open.
...propsReact.HTMLAttributes<HTMLDivElement>—Standard div attributes are forwarded to the grid (role="group"). Give it an aria-label or aria-labelledby.

Accessibility

  • The grid is role="group"; give it an aria-label or aria-labelledby (4.1.2)
  • Each thumbnail is a native button with aria-pressed, named by its label or "Photo N" (4.1.2)
  • The chosen thumbnail is marked by a ring as well as by aria-pressed, and focus draws its own ring at the focus-ring tokens (2.4.7)
  • With prefers-reduced-motion: reduce, the wave and the hover zoom are off (2.3.3)