Carousel
A row you swipe or scroll through, snapping to each item.
| Name | Type | What it does |
|---|---|---|
carousel | component | Container. Its children scroll horizontally and snap into place |
data-carousel="prev" · "next" | part | With behaviors.js loaded: on a button outside the carousel, with aria-controls naming it. Scrolls it by a page |
Swiping, scrolling and arrow keys (once it has focus) work with no script. The buttons need behaviors.js.
Carousel of cards
Tokyo
2,418 photos
Osaka
640 photos
Kyoto
1,102 photos
Nara
88 photos
Sapporo
301 photos
<div style="display: flex; justify-content: flex-end; gap: 0.5rem; margin-bottom: 0.75rem">
<button class="btn btn-circle btn-sm" data-carousel="prev" aria-controls="albums" aria-label="Previous albums">‹</button>
<button class="btn btn-circle btn-sm" data-carousel="next" aria-controls="albums" aria-label="Next albums">›</button>
</div>
<div class="carousel" id="albums" tabindex="0" aria-label="Albums">
<div class="card card-primary" style="width: 14rem"><p class="card-title">Tokyo</p><p>2,418 photos</p></div>
<div class="card" style="width: 14rem"><p class="card-title">Osaka</p><p>640 photos</p></div>
<div class="card card-success" style="width: 14rem"><p class="card-title">Kyoto</p><p>1,102 photos</p></div>
<div class="card" style="width: 14rem"><p class="card-title">Nara</p><p>88 photos</p></div>
<div class="card card-danger" style="width: 14rem"><p class="card-title">Sapporo</p><p>301 photos</p></div>
</div>