--- url: /reference/items/ImageGrid.md --- # ImageGrid A component to display images in a destructured grid. ## Usage Use this component directly in your Twig templates by providing it with an array of objects following the [`Figure` component](../Figure/index.md) parameters. ```twig {% include '@ui/ImageGrid/ImageGrid.twig' with { images: [ { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/600/400', width: 600, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 } ] } %} ``` :::code-group ```js import { registerComponent } from '@studiometa/js-toolkit'; import { Figure } from '@studiometa/ui'; registerComponent(Figure); ``` ::: ### Customizing the image output The `ImageGrid` template exposes an `image` block which can be used to customize the rendering of each image. In the following example, we wrap each image in a [`ScrollReveal` component](../ScrollReveal/index.md) to add transitions when each image becomes visible. ```twig {18-25}
{% embed '@ui/ImageGrid/ImageGrid.twig' with { images: [ { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/600/400', width: 600, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/600/400', width: 600, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/600/400', width: 600, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/500/400', width: 500, height: 400 }, { src: 'https://picsum.photos/600/400', width: 600, height: 400 } ] } %} {% block image %}
{{ parent() }}
{% endblock %} {% endembed %}
``` :::code-group ```js import { registerComponent } from '@studiometa/js-toolkit'; import { Figure, ScrollReveal } from '@studiometa/ui'; registerComponent(Figure); registerComponent(ScrollReveal); ``` :::