A product detail block for Bootstrap 6: a square photo carousel with a thumbnail rail, a photo counter and round arrows, next to a buy box with price, edition picker, quantity stepper, wishlist toggle and an add-to-cart button. It fits online stores, product launch pages and marketplace listings.
How it works
.pct-gallery is the Bootstrap 6 .carousel. The main photo and its overlay sit in .pct-stage, which carries .carousel-overlay so the .carousel-overlay-controls (counter and arrows) are positioned over the photo, not over the thumbnails. Bootstrap 6 builds the slides on CSS scroll-snap, so swiping and trackpad scrolling work without extra code.
The thumbnail strip is a .carousel-indicators element with the extra class .pct-thumbs. Each .pct-thumb button has data-bs-slide-to, so Bootstrap moves .active and aria-current to the matching thumbnail for you; the CSS only restyles the indicator dots as image tiles. From 1024px the gallery becomes a CSS grid and the thumbnails form a vertical rail left of the photo.
The script imports Carousel, creates the instance with ends: 'wrap' and updates .pct-current on slid.bs.carousel. It also recalculates .pct-price-value from data-pct-base when an edition radio changes and clamps the .pct-qty-input stepper between its min and max. It swaps the heart icon when the data-bs-toggle="button" wishlist toggles aria-pressed, and simulates the add-to-cart request with a spinner and an "Added to cart" state.
Customization
--pct-accenton.pct-root: recolors the active thumbnail border, the badge, the edition picker and the Add to cart button. It also feeds--bs-primary-bg, so everytheme-primaryelement follows.--pct-thumbon.pct-root: makes the thumbnail tiles larger or smaller (4.5rem by default).--pct-bgand--pct-lineon.pct-root: change the page background and the divider above the perks list.data-pct-baseon.pct-price-valueand each edition radio'svalue: set the base price and the surcharge.maxon.pct-qty-input: limits how many items can be added (9 here).- Change
aspect-ratioon.pct-imgto4 / 5for portrait product photos such as clothing. - Replace the
setTimeoutin the.pct-addclick handler with afetch()POST to your cart endpoint.
Use cases
- Online stores: shoppers browse product photos with a thumbnail rail and pick an edition before adding to cart
- Product launch pages: pair a square photo carousel with price, quantity stepper and a wishlist toggle
- Marketplace listings: show several photos with a counter and arrows next to a compact buy box
- Digital product shops: switch edition and see the price update while the gallery stays in view
Accessibility
The gallery is a labelled region with aria-roledescription="carousel" and labelled slides. .carousel-inner is focusable, so the Left and Right arrow keys move between photos. Thumbnails are real buttons with labels such as "Photo 2: front view" and aria-current on the active one. The quantity buttons and wishlist have aria-labels, the edition picker is a fieldset with a legend, and the add-to-cart result is announced through a polite role="status" region. Photos have descriptive alt text, and thumbnails use empty alt because their button already has a name.
Bootstrap 6 notes
Bootstrap 6 replaces .carousel-control-prev with buttons using .carousel-icon-prev, the toggle buttons now wrap their input inside label.btn-check, breadcrumbs use .breadcrumb-link and explicit .breadcrumb-divider items, and btn-primary becomes btn-solid theme-primary. This snippet targets 6.0.0-alpha.1, so APIs may still change. The product photos come from Unsplash; replace them with your own images. Icons come from Bootstrap Icons.