Gallery

A set of images shown as a grid.

When to use it

A set of images seen together: the place, the work, the team at an event.

When not to

One image (use image) and images that each need their own text and link (use cards).

Accessibility

Every image needs a description; one that only decorates can have an empty one. Images load as they come into view, at the size each screen needs.

See it live

The component library shows this component in the default theme, in every variant: open it in the component library

The gallery example as the component library shows it in the default theme

Where it is used

The starter sites that use it, each at a page that shows it:

Fields

What the component’s dialog asks for. In a Doc, keyed rows start with the key; rows in order follow the order below.

Field

Key

Kind

Required

Image

image

An image from the assets, with its description

Yes

Variants

This component has no variants of its own; a theme can add some.

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table: The first row of the table here only names the columns; the Doc table is the rows below it.

Column 1

Column 2

Column 3

gallery

[Image]

[Image]

[Image]

In a page file

In a site kept as a folder or in Git, the same component is a block of the page’s JSON file:

JSON
{
  "name": "gallery",
  "rows": [
    [
      {
        "image": "Camp at night"
      },
      {
        "image": "Summit view"
      },
      {
        "image": "River crossing"
      }
    ]
  ]
}

Markup and classes

What the component writes takes these classes, for a theme’s CSS: the component’s own name, name__part for its parts and name--variant for each variant (the variant’s plain name is there too).

Class

What it marks

gallery

The component

The HTML the example above writes, as the component library builds it in the default theme:

html
<ul class="gallery">
    <li><img src="/assets/img/5521e01d770e-1600.webp" srcset="/assets/img/5521e01d770e-400.webp 400w, /assets/img/5521e01d770e-800.webp 800w, /assets/img/5521e01d770e-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px" alt="Camp at night" width="1800" height="900" fetchpriority="high" decoding="async"></li>
    <li><img src="/assets/img/5521e01d770e-1600.webp" srcset="/assets/img/5521e01d770e-400.webp 400w, /assets/img/5521e01d770e-800.webp 800w, /assets/img/5521e01d770e-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px" alt="Summit view" width="1800" height="900" loading="lazy" decoding="async"></li>
    <li><img src="/assets/img/5521e01d770e-1600.webp" srcset="/assets/img/5521e01d770e-400.webp 400w, /assets/img/5521e01d770e-800.webp 800w, /assets/img/5521e01d770e-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px" alt="River crossing" width="1800" height="900" loading="lazy" decoding="async"></li>
</ul>

Extending it

Its files in SeedPage. A theme or a site changes the markup by giving a file of the same name (the Liquid part), and a new component can extend this one.

  • src/components/gallery.js
  • src/components/gallery/gallery.liquid