Media grid
ProSquare 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.
Purpose
Square photo tiles: a row that scrolls sideways on compact windows and a grid from medium windows up, such as a profile's photos or a listing's gallery. Pressing a tile tells the app which, and passes the tile, so it can open MediaViewer there, growing out of the tile (its origin), with what it wants around it. It is not an M3 component, so it comes from @windmorph/react-pro.
Behaviour
maxcaps the tiles shown;columnssets the grid from medium up (3).- On compact windows the row scrolls with snap points; from medium up the grid's outer corners are rounded and inner corners square.
- Images load lazily and fill their square tiles.
- An item's
srcSetin widths lets each tile load the smallest file that fills it. The grid says how wide a tile shows (sizes) from its own layout: the tile's laid-out width where the browser reads it (auto), else the row's 112px tile on compact windows and an equal share of the window from medium up. Pass your ownsizeswhen the grid is narrower than the window (in a column, a card or a dialog), or when the tile's width or the columns are set in CSS, as the example of photos at several widths does. - A photo that can't be loaded keeps its tile: a square in a container colour with an icon (
fallbackIcon) in place of the photo, markeddata-status="error". It is still a button named by the photo'saltand still callsonAction. A failure is noticed in the server's HTML too, where a photo can fail before the page hydrates; a photo with no address shows the placeholder at once; and a newsrcorsrcSetis a new try. onActiongets the pressed tile's index and the tile itself: pass the tile toMediaViewer'soriginfor the M3 container transform.- Each tile shows the core's state layer over its photo (hover, focus) and the press ripple. The list is a Tab stop only while the compact row scrolls.
When not to use
For one large swipeable set use a Carousel; for photos being uploaded, the Media upload grid.
See also
- Media viewer: A full-screen viewer for a set of photos: swipe between them, zoom, and read each caption and position. Not an M3 component (@windmorph/react-pro).
- Media upload grid: The photos someone is adding: upload progress and errors, remove and retry, drag to reorder (mouse, touch or keyboard), an add tile and file drop. Not an M3 component (@windmorph/react-pro).
- Carousel: A scrollable row of items that resize along keylines: multi-browse, uncontained, multi-aspect, hero or full-screen.