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
<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.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add media-gridUsage
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.
MediaGridMediaGrid.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.
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The list's accessible name, such as "Posts". |
columns | number | No | How many tiles to a row. Default: 3. |
children | RemixNode | Yes | MediaGrid.Item elements in order. |
Also accepts everything in Omit<TagProps<"ul">, "children">.
MediaGrid.Item
| Prop | Type | Required | Description |
|---|---|---|---|
href | string | Yes | Where the tile leads: the post or the video. |
label | string | Yes | The link's accessible name, such as "Post by Mara: bowls cooling on a plank". |
children | RemixNode | Yes | The picture, drawn edge to edge and cropped to the tile: an <img>, an <svg>, a <video>. |
tall | boolean | No | Stands two rows tall, for a video among photos. |
badge | RemixNode | No | An icon in the top corner, such as a stack for several photos or a film for a video. |
overlay | RemixNode | No | What shows over the picture on hover or focus, such as its likes and comments. |
Also accepts everything in Omit<TagProps<"li">, "children">.