Display
Media Grid
Image, video and document tiles for a chat message that open a Lightbox gallery.
<script>
import { MediaGrid } from "@codeatlasdev/ui";
</script>
<MediaGrid items={[{ src: "/a.jpg", alt: "Beach" }, { type: "video", src: "/b.mp4", thumb: "/b.jpg", duration: "0:12" }]} />
Tiles keep their box while the thumbnail loads (a skeleton shows meanwhile) and show an error state if it fails. Past maxVisible the last tile reads “+N more” and opens the gallery at that index. Images and videos open a Lightbox with previous and next; documents are plain download links and stay out of the gallery.
Mixed media
Images, a video, a document and the +N overflow tile.
Reference #253 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | MediaGridItem[] | – | { type?, src, thumb?, alt?, title?, caption?, meta?, duration?, poster?, download?, size? }. |
maxVisible | number | 4 | Tiles shown before the +N overflow tile. |
columns | 1 | 2 | 3 | – | Defaults by item count. |
label | string | – | Accessible name of the group. |
onopen | (index: number, item: MediaGridItem) => void | – | Called when a tile is opened. |
ondownload | (item, index) => void | – | Forwarded to the Lightbox Download button. |