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 itselfBbDialog, 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.
<template>
<div class="grid max-w-md gap-3">
<div class="grid grid-cols-4 gap-2">
<!-- Any element opens it: `item` is the photo's index in `items`. -->
<button
v-for="(photo, i) in housePhotos.slice(0, 4)"
:key="photo.src"
v-bb-gallery="{ id: 'gallery-casa', item: i }"
class="cursor-zoom-in overflow-hidden rounded-(--bb-radius)"
type="button"
>
<img :alt="photo.alt" class="aspect-square w-full object-cover" :src="photo.thumb" >
</button>
</div>
<!-- No item: it opens on the first photo. -->
<BbButton v-bb-gallery="'gallery-casa'" class="self-start" size="sm" variant="outline">
Show all {{ housePhotos.length }} photos
</BbButton>
<BbGallery id="gallery-casa" :items="housePhotos" title="Casa Calma" />
</div>
</template>
<script setup lang="ts">
import { BbButton, BbGallery, vBbGallery } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
</script>
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
<template>
<div class="grid max-w-md gap-3">
<p class="m-0 text-sm">
Viewing: {{ index === null ? 'nothing' : housePhotos[index]?.caption }}
</p>
<BbButton class="self-start" size="sm" variant="outline" @click="index = 2">
Open the dining room
</BbButton>
<!-- `null` while closed; any number opens it on that photo. -->
<BbGallery v-model="index" :items="housePhotos" loop title="Casa Calma" />
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BbButton, BbGallery } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
const index = ref<number | null>(null);
</script>
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.
From a carousel
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.
<template>
<div class="max-w-2xl">
<BbCarousel
v-model="current"
class="[--ratio:3/2]"
:items="housePhotos"
label="Casa Calma, photos"
>
<template #overlay="{ index }">
<BbButton
v-bb-gallery="{ id: 'gallery-carousel', item: index }"
class="absolute top-3 right-3"
icon-only
prepend:icon="lucide:maximize-2"
size="sm"
:text="`View photo ${index + 1} full screen`"
variant="secondary"
/>
</template>
</BbCarousel>
<!-- Closing on another photo leaves the carousel on it. -->
<BbGallery
id="gallery-carousel"
:items="housePhotos"
title="Casa Calma"
@update:model-value="follow"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BbButton, BbCarousel, BbGallery, vBbGallery } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
const current = ref(0);
const follow = (index: number | null) => {
if (index !== null) current.value = index;
};
</script>
A filmstrip in the viewer
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.
<template>
<BbButton class="self-start" variant="outline" @click="index = 0">
Open with a filmstrip
</BbButton>
<BbGallery v-model="index" :items="housePhotos" title="Casa Calma">
<!-- A picker carousel bound to the slot's index, its picks sent to `go`. -->
<template #footer="{ index: shown, go }">
<BbCarousel
class="w-full max-w-xl [--gap:6px] [--per-view:5.5] [--ratio:3/2]"
:items="thumbnails"
label="Thumbnails"
:model-value="shown"
picker
@update:model-value="go"
/>
</template>
</BbGallery>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BbButton, BbCarousel, BbGallery } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
const thumbnails = housePhotos.map(({ thumb, alt }) => ({ src: thumb, alt }));
const index = ref<number | null>(null);
</script>
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.
<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>.







