Skip to content

BbCarousel

Slides moved by swipe, arrows and dots.

import { BbCarousel } from 'bitboss-ui';

On this page

Props

NameDescription
align Type: "start" | "center"Defaultundefined (the local's own default: start)

Where the current slide sits: start (the column's start edge) or center (the middle, neighbours peeking on both sides). Sets the --align local; leave it out to set the local yourself, never both (bitboss-ui/carousel-prop-or-local).

autoplay Type: number | booleanDefaultfalse

Advance on a timer, in ms (true = 5000). Pauses while hovered, while focus is inside and with the pause button; never runs under prefers-reduced-motion.

Keep it for decorative rotation: content the reader must see should not move on its own.

See example
bleed Type: booleanDefaultundefined (no bleed)

Lets the slides run past the carousel to the page edge, while they still snap to and size from the carousel (--bleed: auto). Leave it out to set the --bleed locals yourself (a length, one side, per breakpoint); never both (bitboss-ui/carousel-prop-or-local).

items Type: number | readonly T[]

The slides as data, rendered through the slide slot (item is the entry; with a number, that many slides and item is the index). Without the slot, an image URL or a { src, alt } entry renders as a cover image. Without items, each default-slot child is a slide.

Photo entries ({ src, alt }) need no slot. Any other entry goes through the slide slot, which also wins over the built-in image.

See example
label Type: string

The carousel's accessible name. Default: the locale's "Carousel".

See example
loop Type: booleanDefaultfalse

An endless run: buttons, keys, autoplay, a swipe and a mouse drag all carry on past the last slide into the first (and back), with no rewind.

See example
modelValue Type: numberDefault0

The current slide, 0-based, never clamped to a scroll position: the view shows the page that holds it. Out of range, it is brought back and written back.

perView Type: numberDefaultundefined (the local's own default: 1)

Slides in view; a fraction shows a peek of the next (1.2). Sets the --per-view local. Leave it out to set the local yourself, for instance per breakpoint (class="[--per-view:1.2] md:[--per-view:3]"); never both (bitboss-ui/carousel-prop-or-local).

For a value per breakpoint, set the --per-view local in a class instead ([--per-view:1.3] sm:[--per-view:3]). Use one or the other, never both.

See example
picker Type: booleanDefaultfalse

A strip that picks the current slide (thumbnails under a big photo on the same v-model): steps one at a time, keeps the current one in the middle slot, a swipe only browses. Its arrows and dots stay hidden (pt brings them back); without a slide slot each built-in image is a button.

Bind the strip and the main carousel to the same v-model; no sync code.

See example
pt Type: (PtCompoundOf<"", { readonly parts: readonly ["root", "slide", "image", "thumb", "overlay", "prev", "next", "dots", "dot", "pause"]; readonly states: readonly ["current", "disabled", "active"]; readonly wide: readonly []; readonly node: { readonly slide: readonly ["active", "current"]; readonly dot: readonly ["active"]; readonly prev: readonly ["disabled"]; readonly next: readonly ["disabled"]; }; }> & { image?: PtValue | undefined; pause?: PtValue | undefined; next?: PtValue | undefined; root?: PtValue | undefined; slide?: PtValue | undefined; thumb?: PtValue | undefined; overlay?: PtValue | undefined; prev?: PtValue | undefined; dots?: PtValue | undefined; dot?: PtValue | undefined; "slide:active"?: PtValue | undefined; "dot:active"?: PtValue | undefined; "slide:current"?: PtValue | undefined; "next:disabled"?: PtValue | undefined; "prev:disabled"?: 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: dot, dots, image, next, overlay, pause, prev, root, slide, thumb. States: active, current, disabled.

See example

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: numberSee example

Events

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

Emitted with the new value whenever v-model changes.

Slots

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

NameDescription
default Type: any

The slides: one per child.

overlay Type: BbCarouselSlotProps<T | undefined>

A layer on top of each slide (any kind), moving with it: captions, badges, glyphs, buttons.

See example
slide Type: BbCarouselSlotProps<T>

One slide's content, from items (replaces the built-in image).

See example
slide:footer Type: BbCarouselSlotProps<T | undefined>

Below each slide's content, inside the slide (any kind of slide): a caption, a price, a link.

See example
slide:header Type: BbCarouselSlotProps<T | undefined>

Above each slide's content, inside the slide (any kind of slide; the built-in image keeps its lazy loading, sizes and crop): a kicker, a title.