Skip to content

BbGallery

A full-screen photo viewer (lightbox): swipe, arrows, keys, zoom; also the v-bb-gallery directive.

import { BbGallery } from 'bitboss-ui';

On this page

Props

NameDescription
closeOnBackdropClick Type: booleanDefaultfalse

A click (or a tap) on the dark area around the photo closes the viewer. Off, it does nothing there (a tap still hides the bars); Escape, the close button and a swipe down always close.

id Type: string

The name v-bb-gallery opens it by, nearest to the trigger first. Also the viewer's DOM id.

What v-bb-gallery opens it by: v-bb-gallery="'trip'" on the first photo, v-bb-gallery="{ id: 'trip', item: 2 }" on a given one. Import vBbGallery from bitboss-ui.

See example
items requiredType: readonly (string | T)[]

The photos, in order: { src, alt, caption, … } entries or image URLs.

Pass width and height when you know them: the viewer reserves the box before the file arrives and never upscales it.

See example
loop Type: booleanDefaultfalse

Previous on the first photo goes to the last, next on the last to the first (buttons, keys and a swipe).

See example
modelValue Type: number | nullDefaultnull

The photo in the viewer, null while it is closed. Bind it to open the viewer yourself; v-bb-gallery opens it without one.

pt Type: (PtCompoundOf<"", { readonly parts: readonly ["root", "header", "title", "close", "slide", "image", "caption", "prev", "next", "footer", "counter", "more"]; readonly states: readonly ["disabled", "active", "zoomed"]; readonly wide: readonly ["zoomed"]; readonly node: { readonly slide: readonly ["active"]; readonly prev: readonly ["disabled"]; readonly next: readonly ["disabled"]; }; }> & { caption?: PtValue | undefined; footer?: PtValue | undefined; header?: PtValue | undefined; title?: PtValue | undefined; image?: PtValue | undefined; next?: PtValue | undefined; root?: PtValue | undefined; close?: PtValue | undefined; slide?: PtValue | undefined; prev?: PtValue | undefined; "slide:active"?: PtValue | undefined; "next:disabled"?: PtValue | undefined; "prev:disabled"?: PtValue | undefined; counter?: PtValue | undefined; more?: PtValue | undefined; "caption:zoomed"?: PtValue | undefined; "footer:zoomed"?: PtValue | undefined; "header:zoomed"?: PtValue | undefined; "title:zoomed"?: PtValue | undefined; "image:zoomed"?: PtValue | undefined; "next:zoomed"?: PtValue | undefined; "root:zoomed"?: PtValue | undefined; "close:zoomed"?: PtValue | undefined; "slide:zoomed"?: PtValue | undefined; "prev:zoomed"?: PtValue | undefined; "counter:zoomed"?: PtValue | undefined; "more:zoomed"?: PtValue | undefined; })

Passthrough, object form: the same keys as the pt:* attributes without the prefix.

pt:<part> Type: PtValue

Passthrough, attribute form: one attribute per part, pt:<part>, and per part and state, pt:<part>:<state>. Parts: caption, close, counter, footer, header, image, more, next, prev, root, slide, title. States: active, disabled, zoomed.

See example
title Type: string

A title in the top bar, also the viewer's accessible name. Unset, the bar shows only the close button and the name is the locale's "Gallery".

See example

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: number | nullSee example

Events

NameDescription
update:modelValue Type: (value: number | null): void

Emitted with the new value whenever v-model changes.

See example

Slots

The listed properties are the ones exposed to the slot scope.

NameDescription
header Type: BbGalleryHeaderSlotProps<T>

Replaces the whole top bar (title and close button), so it owns closing: wire your control to close, and titleId onto your title.

title Type: BbGalleryTitleSlotProps<T>

Replaces the title text in the top bar; it still names the viewer.