Preset

Accent

Gallery

wb-gallery is the canonical inline media pattern for equal-tile image grids. When the job needs immersive viewing, the same gallery can populate one shared wb-modal viewer instead of becoming a separate lightbox system.

Pattern boundary wb-gallery is good at equal-tile responsive image collections and one shared modal viewer. It is not a layout system, not masonry, not a featured-grid pattern, and not a carousel.

Use this page when the job is to present a set of images cleanly in the page flow, optionally with captions and one shared viewer modal. If you need mixed media, zoom, hero-plus-thumbnails, or uneven tile sizing, the current shipped contract is the wrong fit.

When to use

  • Image collections
  • Screenshot sets
  • Editorial visuals
  • Inline content galleries
Do not use it for Masonry layouts, featured-grid spans, sliders, carousels, zoom tooling, or mixed-media viewers. Those capabilities are not present in the shipped source.

Core contract

Keep the base markup small. The gallery pattern is an inline grid wrapper, an item wrapper, one interactive trigger, one image, and optional caption or meta text.

<div class="wb-gallery" aria-label="Release gallery">
  <div class="wb-gallery-grid">
    <figure class="wb-gallery-item">
      <button class="wb-gallery-trigger"
              type="button"
              data-wb-gallery-target="#releaseViewer"
              data-wb-gallery-full="/images/release-full.jpg">
        <img class="wb-gallery-media"
             src="/images/release-thumb.jpg"
             alt="Release dashboard screenshot">
      </button>
      <figcaption class="wb-gallery-caption">Release dashboard</figcaption>
      <div class="wb-gallery-meta">Shared viewer modal</div>
    </figure>
  </div>
</div>
HookReal supportNotes
data-wb-gallery-targetYesPreferred gallery-to-modal connection hook.
data-wb-targetYesAccepted as a fallback modal selector source.
data-wb-gallery-fullYesFull-size viewer image source.
data-wb-gallery-altYesViewer alt text override.
data-wb-gallery-captionYesViewer caption override.
data-wb-gallery-metaYesViewer meta override.
data-wb-gallery-widthYesOptional width attribute for viewer image.
data-wb-gallery-heightYesOptional height attribute for viewer image.
<div class="wb-modal wb-modal-xl" id="releaseViewer" role="dialog" aria-modal="true" aria-labelledby="releaseViewerTitle">
  <div class="wb-modal-dialog">
    <div class="wb-modal-body">
      <div class="wb-gallery-viewer">
        <div class="wb-gallery-viewer-toolbar">
          <button class="wb-gallery-viewer-prev" type="button" aria-label="Previous image">...</button>
          <div class="wb-gallery-viewer-counter" aria-live="polite">1 / 3</div>
          <button class="wb-gallery-viewer-next" type="button" aria-label="Next image">...</button>
          <button class="wb-gallery-viewer-close" type="button" data-wb-dismiss="modal" aria-label="Close viewer">...</button>
        </div>
        <figure class="wb-gallery-viewer-media">
          <img class="wb-gallery-viewer-image" src="..." alt="...">
          <figcaption class="wb-gallery-viewer-caption" id="releaseViewerTitle"></figcaption>
        </figure>
        <p class="wb-gallery-viewer-meta"></p>
      </div>
    </div>
  </div>
</div>

Official examples

These six examples are the strongest current uses of wb-gallery. Each one demonstrates a different job without pretending the pattern can do masonry, featured spans, or slider behavior.

1. Inline captioned gallery

Baseline pattern: equal tiles with one visible caption per image. This example uses the same shared viewer pattern for a consistent docs experience.

3. Shared modal viewer gallery

Behavior example: one gallery set, one modal, prev/next controls, viewer counter, and caption/meta population from real trigger attributes.

Single-modal rule The viewer stays inside one shared wb-modal. The gallery runtime does not invent a second overlay system or a separate lightbox primitive.

Composition guidance

wb-gallery combines cleanly with wb-card, wb-content-shell, wb-stack, wb-split, and wb-grid-* helpers. These are composition patterns, not gallery variants.

Keep the vocabulary honest The gallery contract stays the same. Changing the surrounding shell, card, or stack does not create a new gallery primitive or a new gallery layout system.

Do / Do not

Do

Use equal-importance image sets.

Keep one shared viewer modal for the gallery context instead of duplicating viewers per example.

Use real captions and optional meta only when they add context.

Combine with content shells, cards, and layout helpers when the page job needs it.

Do not

Do not imply masonry.

Do not imply featured spans or hero-plus-thumbnails.

Do not imply carousel, zoom, or mixed-media support.

Do not add docs-only helper classes just to fake unsupported gallery behavior.

Accessibility / behavior notes

Alt textThe viewer uses data-wb-gallery-alt first, then falls back to the inline image alt.
Caption and metaThe viewer reads data-wb-gallery-caption and data-wb-gallery-meta first, then falls back to wb-gallery-caption and wb-gallery-meta text.
Modal labelingIf a viewer caption is present and has an id, the modal uses aria-labelledby. Otherwise it falls back to an aria-label from caption, alt, or the text "Gallery viewer".
Keyboard navigationWhen the shared viewer modal is active, left and right arrow keys step through items unless focus is inside an input, textarea, or editable field.
Scoped steppingPrev and next only step through triggers inside the same .wb-gallery that point to the same modal selector.
Boundary behaviorPrev and next controls are disabled at the beginning and end of the active item list.