SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

MediaGrid

A grid of photos and videos as links, three square tiles to a row with a hairline gap, the way a profile or an explore page lays out a person's pictures.

View code
tsx
<MediaGrid label="Posts">
	{posts.map((post) => (
		<MediaGrid.Item
			href={post.href}
			label={post.alt}
			tall={post.video}
			badge={post.video ? <FilmIcon /> : post.many ? <LayersIcon /> : undefined}
			overlay={<span><HeartIcon fill="currentColor" /> {post.likes}</span>}
		>
			<img src={post.thumb} alt="" />
		</MediaGrid.Item>
	))}
</MediaGrid>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add media-grid

Usage

typescript
import { MediaGrid } from "@sdxc/ui";

Renders the grid. Tiles flow densely, so a tall tile never leaves a hole; the gap reads --ui-media-grid-gap, a hairline unless a page widens it.

Composition

The parts the component publishes, each a static property of the host.

  • MediaGrid
  • MediaGrid.ItemOne tile: a link holding the picture, square or two rows tall, with its badge and an overlay that fades in over a scrim while the tile is hovered or focused.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
labelstringYesThe list's accessible name, such as "Posts".
columnsnumberNoHow many tiles to a row. Default: 3.
childrenRemixNodeYesMediaGrid.Item elements in order.

Also accepts everything in Omit<TagProps<"ul">, "children">.

MediaGrid.Item

PropTypeRequiredDescription
hrefstringYesWhere the tile leads: the post or the video.
labelstringYesThe link's accessible name, such as "Post by Mara: bowls cooling on a plank".
childrenRemixNodeYesThe picture, drawn edge to edge and cropped to the tile: an <img>, an <svg>, a <video>.
tallbooleanNoStands two rows tall, for a video among photos.
badgeRemixNodeNoAn icon in the top corner, such as a stack for several photos or a film for a video.
overlayRemixNodeNoWhat shows over the picture on hover or focus, such as its likes and comments.

Also accepts everything in Omit<TagProps<"li">, "children">.

@sdxc/ui

Can’t find it? Contact us