Use it for
Use BbCarousel for a short run of slides the reader steps through: a listing's photos, a row of product cards, onboarding screens. Swipe, drag, arrows and keys all work out of the box.
Always give the carousel a label: screen readers announce it as a carousel of that name.
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.
Show photos
Pass the photos as items, each with a src and an alt. They render as cover-cropped images, with no slot to write.
<template>
<!-- Photo entries need no slot: each one renders as a cover-cropped image. -->
<BbCarousel
class="max-w-2xl [--ratio:3/2]"
:items="housePhotos"
label="Casa Calma, photos"
/>
</template>
<script setup lang="ts">
import { BbCarousel } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
</script>
The crop is the --ratio local, 16 / 9 by default; set it in a class ([--ratio:3/2]). A photo without alt is treated as decorative. The photos in view and their neighbours load at once, the rest as the reader gets near them.
Without items, each child of the default slot is one slide.
Several per view
Set per-view, or the --per-view local when it changes per breakpoint. A fraction shows a peek of the next slide, so a phone reader knows there is more.
<template>
<!-- One card and a peek on a phone, three from `sm`: the dots are pages. -->
<BbCarousel
class="[--per-view:1.3] sm:[--per-view:3]"
:items="shopItems"
label="Fresh from the roastery"
>
<template #slide="{ item }">
<article class="grid gap-2">
<img
:alt="item.photo.alt"
class="aspect-[4/3] w-full rounded-(--bb-radius) object-cover"
loading="lazy"
:src="item.photo.src"
>
<div class="grid gap-0.5 text-sm">
<p class="m-0 font-medium">{{ item.name }}</p>
<p class="m-0 flex items-baseline gap-2">
<span class="font-semibold">{{ item.price }}</span>
<s v-if="item.was" class="text-(--bb-text-muted)">{{ item.was }}</s>
</p>
</div>
</article>
</template>
</BbCarousel>
</template>
<script setup lang="ts">
import { BbCarousel } from 'bitboss-ui';
import { shopItems } from '~/demo-data';
</script>
Use the slide slot for anything that is not a bare photo; item is typed as your entry. With several in view the carousel moves a page at a time, and there is one dot per page.
Set a value with the prop or with the local, never both (the bitboss-ui/carousel-prop-or-local lint rule flags it). The spacing is --gap, never a gap-* class.
A thumbnail strip
Bind two carousels to the same v-model and add picker to the strip. A tap on a thumbnail moves the photo above, with no sync code.
<template>
<div class="grid max-w-2xl gap-3">
<BbCarousel
v-model="current"
class="[--ratio:3/2]"
:items="housePhotos"
label="Casa Calma, photos"
/>
<!-- Same v-model: a tap on a thumbnail picks the photo above. -->
<BbCarousel
v-model="current"
class="[--gap:8px] [--per-view:4.5] [--ratio:3/2] sm:[--per-view:6]"
:items="thumbnails"
label="Choose a photo"
picker
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BbCarousel } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
// The strip loads the small files.
const thumbnails = housePhotos.map(({ thumb, alt }) => ({ src: thumb, alt }));
const current = ref(0);
</script>
v-model is the current slide, 0-based. A picker hides its own arrows and dots: the thumbnails are the control, and each one is a button named by its alt.
Loop and autoplay
loop makes the run endless. autoplay turns the slides on a timer: true is every 5 seconds, or pass milliseconds.
<template>
<!-- `pt:dot` hides the dots and keeps the pause button; `pt:dots` would hide both. -->
<BbCarousel
:autoplay="4500"
:items="headlines"
label="Announcements"
loop
pt:dot="hidden"
>
<template #slide="{ item }">
<p
class="m-0 grid min-h-10 place-items-center rounded-(--bb-radius) bg-(--bb-primary) px-12 py-2 text-center text-sm font-medium text-(--bb-primary-fg)"
>
{{ item }}
</p>
</template>
</BbCarousel>
</template>
<script setup lang="ts">
import { BbCarousel } from 'bitboss-ui';
const headlines = [
'Free shipping on orders over € 40, in Italy and the EU.',
'The new Huila is in: washed, panela and red apple.',
'Returns are free for 30 days, opened bags included.',
];
</script>
Autoplay pauses on hover, on focus and off screen, and never runs for readers who ask for reduced motion. It always shows a pause button, at the start of the dots row, with a target of at least 24px for a mouse and 44px on touch. Keep it for decorative rotation: content the reader must see should not move on its own.
Content on the slides
The overlay slot lays content over every slide and moves with it: a caption, a counter, a badge, a save button. Place it yourself; the layer is the size of the slide.
<template>
<BbCarousel
class="max-w-2xl [--ratio:3/2]"
:items="housePhotos"
label="Casa Calma, photos"
>
<template #overlay="{ item, index }">
<span
class="absolute top-3 left-3 rounded-full bg-black/60 px-2 py-0.5 text-xs text-white tabular-nums"
aria-hidden="true"
>
{{ index + 1 }} / {{ housePhotos.length }}
</span>
<!-- A scrim under the text, and room at the bottom for the dots. -->
<p
v-if="item?.caption"
class="absolute inset-x-0 bottom-0 m-0 bg-linear-to-t from-black/75 to-transparent px-4 pt-10 pb-10 text-sm font-medium text-white"
>
{{ item.caption }}
</p>
</template>
</BbCarousel>
</template>
<script setup lang="ts">
import { BbCarousel } from 'bitboss-ui';
import { housePhotos } from '~/demo-data';
</script>
Put text over a photo on a scrim, and keep the bottom clear for the dots. Name every button for what it does. For a title or a price under each slide instead, use slide:footer (or slide:header above it).











