Skip to content

Media grid

Pro

Square photo tiles, a sideways row on compact windows and a grid from medium up; a press on a tile reports it (`onAction`), for the app to open the viewer. Not an M3 component (@windmorph/react-pro).

import { MediaGrid } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Keyboard

Media grid keyboard
KeyAction
TabMoves focus to the list while it scrolls (the compact row), then to each tile in turn. Every tile is its own Tab stop.
Arrow Left or Arrow RightScrolls the compact row sideways while the list has focus.On the list
Enter or SpacePresses the tile: onAction gets its index and the tile, usually to open MediaViewer there, growing out of the tile (origin).On a tile

Screen reader

Role
A list (ul) of list items, each holding a button.
Accessible name
The list is named by its required aria-label ("Photos"); each tile by its photo's alt.
States announced
None. Screen readers read the number of items from the list.
  • Only the first max photos are rendered, so the count is of the tiles shown.
  • A tile whose photo can't be loaded is still a button named by its alt, and still calls onAction. Its placeholder icon is hidden from assistive tech, and the failure is not announced on the tile.

Focus

  • While the compact row scrolls, the list itself is focusable (tabIndex={0}), so a keyboard can scroll it (WCAG 2.1.1). From medium windows up, where the grid does not scroll, it is not a Tab stop.
  • Each tile shows M3's focus indicator inside its edge on keyboard focus (a 3px secondary outline drawn inset), so the row never clips it. Pointer presses show no ring.

Touch target

In the compact row each tile is 112 × 112px (tile-width). From medium windows up a tile is a square of the grid's width divided by columns (3 by default), less the 4px gaps.

Motion

Each tile shows the core's state layer over its photo (hover, focus) and the press ripple. Under reduced motion the ripple appears at full size without growing.

What you need to do

  • Name the list with aria-label, and give every photo an alt that says what it shows: it is the tile's only name.
  • Open something useful from onAction, such as MediaViewer on that photo, so pressing a tile always does something.
  • When max hides photos, offer a way to reach the rest, such as a "See all photos" link.
  • A failed photo's tile still calls onAction: open something that says the photo can't be shown, as MediaViewer does, or offer another try.