# 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: a tile can stand two rows tall, carry a badge in its corner and show an overlay (likes, a count) on hover or focus.

```ts
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.

## Examples

```tsx
<MediaGrid label="Posts">
	{posts.map((post) => (
		<MediaGrid.Item href={post.href} label={post.alt} badge={post.many ? <LayersIcon /> : null}>
			<img src={post.thumb} alt="" />
		</MediaGrid.Item>
	))}
</MediaGrid>
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `label` | `string` | The list's accessible name, such as "Posts". |
| `columns?` | `number` | How many tiles to a row. Default: `3`. |
| `children` | `RemixNode` | MediaGrid.Item elements in order. |

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


### MediaGrid.Item

One 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.

| Prop | Type | Description |
| --- | --- | --- |
| `href` | `string` | Where the tile leads: the post or the video. |
| `label` | `string` | The link's accessible name, such as "Post by Mara: bowls cooling on a plank". |
| `children` | `RemixNode` | The picture, drawn edge to edge and cropped to the tile: an `<img>`, an `<svg>`, a `<video>`. |
| `tall?` | `boolean` | Stands two rows tall, for a video among photos. |
| `badge?` | `RemixNode` | An icon in the top corner, such as a stack for several photos or a film for a video. |
| `overlay?` | `RemixNode` | What shows over the picture on hover or focus, such as its likes and comments. |

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

