Carousel
A Duostrap carousel with continuous scrolling, snap points, responsive slides, and keyboard navigation.
Duostrap Carousel preserves the classic 40×40px circular #222 translucent navigation controls (‹ / ›) and dark caption bar while inheriting Base Carousel’s continuous drag/scroll engine, snap alignment, responsive slide sizing, and keyboard navigation.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-carousel-root
id="bootstrap-carousel-hero"
class="mx-auto w-full max-w-md"
>
<proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-slide>
1
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
2
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
3
</proto-ui-duostrap-carousel-slide>
</proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-previous>
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous slide</span>
</proto-ui-duostrap-carousel-previous>
<proto-ui-duostrap-carousel-next>
<span aria-hidden="true">›</span>
<span class="sr-only">Next slide</span>
</proto-ui-duostrap-carousel-next>
</proto-ui-duostrap-carousel-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bootstrap-carousel-hero');
if (root instanceof HTMLElement)
setElementProps(root, { a11yLabel: 'Featured slides' });
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
import { DuostrapCarouselRoot, DuostrapCarouselViewport, DuostrapCarouselSlide, DuostrapCarouselPrevious, DuostrapCarouselNext,} from '../proto-ui/components/react';
export function Example() { return ( <DuostrapCarouselRoot className="mx-auto w-full max-w-lg"> <DuostrapCarouselViewport> <DuostrapCarouselSlide>Slide 1</DuostrapCarouselSlide> <DuostrapCarouselSlide>Slide 2</DuostrapCarouselSlide> </DuostrapCarouselViewport> <DuostrapCarouselPrevious aria-label="Previous slide">‹</DuostrapCarouselPrevious> <DuostrapCarouselNext aria-label="Next slide">›</DuostrapCarouselNext> </DuostrapCarouselRoot> );}- Classic glyph controls:
PreviousandNextare sized for single‹/›glyphs (60pxlight typography inside40×40pxrings); always pair them withsr-onlytext oraria-labelinstead of visible multi-word strings. - Responsive sizing and snapping: Configure
slidesPerView(default1) andminSlideSize(default0) to show multiple equal-width slides; set an explicit bounded height onViewportfororientation="vertical". - Controlled index: Pass
indexand listen toindexChangefor controlled updates, or setloop={true}to wrap between the first and last reachable stops.
Examples
Section titled “Examples” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-carousel-root
id="bootstrap-carousel-sizes"
class="mx-auto w-full max-w-md"
>
<proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-slide>
1
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
2
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
3
</proto-ui-duostrap-carousel-slide>
</proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-previous>
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous slide</span>
</proto-ui-duostrap-carousel-previous>
<proto-ui-duostrap-carousel-next>
<span aria-hidden="true">›</span>
<span class="sr-only">Next slide</span>
</proto-ui-duostrap-carousel-next>
</proto-ui-duostrap-carousel-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bootstrap-carousel-sizes');
if (root instanceof HTMLElement)
setElementProps(root, { slidesPerView: 2, minSlideSize: 180 });
</script>Orientation
Section titled “Orientation” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-carousel-root
id="bootstrap-carousel-orientation"
class="mx-auto w-full max-w-md"
>
<proto-ui-duostrap-carousel-viewport class="h-56">
<proto-ui-duostrap-carousel-slide>
1
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
2
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
3
</proto-ui-duostrap-carousel-slide>
</proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-previous>
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous slide</span>
</proto-ui-duostrap-carousel-previous>
<proto-ui-duostrap-carousel-next>
<span aria-hidden="true">›</span>
<span class="sr-only">Next slide</span>
</proto-ui-duostrap-carousel-next>
</proto-ui-duostrap-carousel-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector(
'#bootstrap-carousel-orientation'
);
if (root instanceof HTMLElement)
setElementProps(root, { orientation: 'vertical' });
</script> Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-carousel-root
id="bootstrap-carousel-loop"
class="mx-auto w-full max-w-md"
>
<proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-slide>
1
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
2
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
3
</proto-ui-duostrap-carousel-slide>
</proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-previous>
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous slide</span>
</proto-ui-duostrap-carousel-previous>
<proto-ui-duostrap-carousel-next>
<span aria-hidden="true">›</span>
<span class="sr-only">Next slide</span>
</proto-ui-duostrap-carousel-next>
</proto-ui-duostrap-carousel-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bootstrap-carousel-loop');
if (root instanceof HTMLElement)
setElementProps(root, { loop: true });
</script> Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-carousel-root
id="bootstrap-carousel-api"
class="mx-auto w-full max-w-md"
>
<proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-slide>
1
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
2
</proto-ui-duostrap-carousel-slide>
<proto-ui-duostrap-carousel-slide>
3
</proto-ui-duostrap-carousel-slide>
</proto-ui-duostrap-carousel-viewport>
<proto-ui-duostrap-carousel-previous>
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous slide</span>
</proto-ui-duostrap-carousel-previous>
<proto-ui-duostrap-carousel-next>
<span aria-hidden="true">›</span>
<span class="sr-only">Next slide</span>
</proto-ui-duostrap-carousel-next>
</proto-ui-duostrap-carousel-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bootstrap-carousel-api');
if (root instanceof HTMLElement)
setElementProps(root, { defaultIndex: 0 });
</script>| Prop | Type | Default |
|---|---|---|
index | number | — |
defaultIndex | number | 0 |
slidesPerView | number | 1 |
minSlideSize | number | 0 |
loop | boolean | false |
disabled | boolean | false |
orientation | 'horizontal' 'vertical' | horizontal |
direction | 'ltr' 'rtl' | ltr |
a11yLabel | string | Carousel |
Other parts & exposed states
Section titled “Other parts & exposed states”| Part / Prop | Type | Default |
|---|---|---|
Slide.index | number | Document order |
Previous / Next.disabled | boolean | false |
- Root: exposes
index,slideCount,visibleSlides,maxIndex, methodrequestIndex(next), and eventindexChange. - Viewport: exposes
focusVisible,dragging,scrolling, andscrollPosition. - Slide: exposes
current,hidden,basis, andminSize.