Skip to content
bitboss-ui3.0.0-beta.79

BbGallery

A full-screen photo viewer opened from your thumbnails, a button or a carousel, with swipe and zoom.

import { BbGallery } from 'bitboss-ui';

On this page

Use it for

Use BbGallery when a photo deserves the whole screen: a listing's photos, a product's shots, a portfolio. It is only the viewer and draws nothing on the page; your thumbnails, button or carousel open it.

Use something else when

  • BbCarousel, when the photos step on the page itself
  • BbDialog, when the content is not photos

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Open photos full screen

Give the gallery an id and put v-bb-gallery on whatever opens it. item names the photo, by its index in items or by its URL.

With only the id (v-bb-gallery="'gallery-casa'", mind the inner quotes) it opens on the first photo. Import vBbGallery from bitboss-ui next to the component. Focus comes back to the trigger on close.

Each photo takes a src and an alt, plus an optional caption for the bottom bar. Pass width and height when you know them: the viewer reserves the box before the file arrives, and never stretches a small photo.

Open it from code

v-model is the index of the photo shown, null while the viewer is closed. Set it to open the viewer; it follows every swipe and goes back to null on close.

Viewing: nothing

loop wraps from the last photo to the first. Swipe, arrows, Home and End, double-click or pinch to zoom, and swipe down or Escape to close all work without setup.

Put the trigger in the carousel's overlay slot, with the slide's index as item. Listen to update:modelValue to leave the carousel on the photo the viewer closed on.

The footer slot replaces the counter. Put a BbCarousel with picker there: bind it to the slot's index and send its picks to go.

The caption keeps its own line above your footer. title sits in the top bar and names the viewer for screen readers; the title and header slots replace it.

A light viewer

Every colour in the viewer follows two locals on the root: --viewer-bg and --viewer-fg. Set them with pt:root, plus color-scheme: light.

vue
<BbGallery
    id="trip"
    :items="photos"
    pt:root="[--viewer-bg:rgb(250_248_244)] [--viewer-fg:rgb(28_25_23)] [color-scheme:light]"
    pt:title="font-serif text-2xl"
/>

A scoped <style> does not reach the viewer: it opens in the top layer, outside your component. Use pt classes, or name the root with pt:root and style it from an unscoped <style>.