Skip to content

CdsCarousel

New in v4.0

A carousel shows images or arbitrary content slide by slide: promo banners, photo galleries, onboarding steps. Arrows and delimiter dots give you navigation, autoplay flips the slides on its own, and the progress bar shows the current position.

Storybook GitLab
Test coverage: no tests

This component has no automated tests yet: its behavior is verified manually only.

API in specs
0 / 68 props, events, slots and exposed members with a test
Test cases
0 unit · 0 browser
Code coverage
11.1% lines · 0% branches measured in v4.0.0-alpha.13
A11y (axe)
7 recommendations in 13 stories measured in v4.0.0-alpha.11

To switch content without delimiters and autoplay, take CdsSlideView — the carousel is built on top of it; for a single image take CdsImage.

Anatomy ​

A carousel is made of slides, navigation arrows, delimiter dots and an optional progress bar. Arrows and dots loop around: the first slide follows the last one.

Variations ​

Images ​

CdsCarouselItem combines a slide and CdsImage — pass it any image prop: src, alt, cover, gradient. The height prop sets the height of the carousel (500 by default).

Custom content ​

A slide does not have to be an image: put any markup into the slot of CdsCarouselItem and it stretches over the whole frame.

Autoplay ​

The cycle prop flips the slides automatically, interval sets the pause in milliseconds (6000 by default). The timer restarts after a manual switch, so the reader always has time to finish looking at a slide.

Progress ​

The progress prop adds a position bar at the bottom of the carousel. A string value sets its color — any of the tokens that CdsProgressBar accepts.

Delimiters ​

Props control the navigation dots: hide-delimiters removes them completely, hide-delimiter-background removes only the backdrop, vertical-delimiters (left / right) puts the dots vertically along the edge, and delimiter-icon changes the dot icon.

The item slot replaces a dot with your own element: it receives the ready-made delimiter props (click handler, aria-label, active class) and the group item itself — all that is left is to bind them with v-bind.

Arrows ​

The arrow props are inherited from CdsSlideView: show-arrows="hover" shows them on hover only, :show-arrows="false" removes them completely, prev-icon / next-icon change the icons, and the prev / next slots replace the buttons themselves.

Guidelines ​

Scenarios ​

Promo banners ​

The classic banner rotation: cycle with a 5 second interval flips the slides on its own, progress shows when the next one comes. The text and the button live in the slide slot, and the gradient from CdsImage darkens the top of the frame beneath them — so they stay readable on any image.

The dots are replaced by thumbnails: hide-delimiters removes the built-in delimiters, and a click on a thumbnail changes v-model. The counter next to it reads the same v-model — the carousel, the thumbnails and the counter always stay in sync.

Vertical feed ​

A stories feed in the spirit of social networks: direction="vertical" flips the frames top to bottom, vertical-arrows="left" and vertical-delimiters="right" pull the arrows and the dots apart to the side edges and free up the frame. The author card and the counter sit in an absolute layer above the carousel: pointer-events-none lets clicks through to the arrows, and a transition keyed by v-model swaps the card together with the slide.

Onboarding ​

Product introduction steps: the arrows are off (:show-arrows="false"), the movement is driven by the "Back" and "Next" buttons through v-model. On the last step "Next" turns into a call to action.

API ​

CdsCarousel ​

Props

NameTypeDefaultDescription
colorstring | undefined—Color of the active delimiter and of the progress bar
continuousboolean | undefinedtrueLoops the navigation: from the last slide you move to the first one and back
crossfadeboolean | undefined—Slides change with a smooth crossfade instead of a shift
cycleboolean | undefined—Flips the slides automatically after the given interval
delimiterIconIconValue | undefined'dot'Icon of the delimiter (navigation dot)
direction"horizontal" | "vertical" | undefined'horizontal'Switches the component between horizontal and vertical layout.
disabledboolean | null | undefinednullDisabled state
heightstring | number | undefined500Height of the carousel
hideDelimiterBackgroundboolean | undefined—Hides the backdrop under the delimiters
hideDelimitersboolean | undefined—Hides the delimiters (navigation dots)
intervalstring | number | undefined6000Autoplay interval in milliseconds (when cycle is on)
mandatoryboolean | "force" | undefined'force'Requires at least one item to stay selected
maxnumber | undefined—Maximum number of items that can be selected
modelValueany—Value of the selected items of the group
multipleboolean | undefined—Allows selecting several items at once
nextIconIconValue | undefined'chevron-right'Icon of the button that moves to the next slide
prevIconIconValue | undefined'chevron-left'Icon of the button that moves to the previous slide
progressstring | boolean | undefined—Shows the progress bar of the current slide. A string sets the color of the bar
requiredboolean | "force" | undefined—Requires at least one item to stay selected
reverseboolean | undefined—Inverts the direction of the transition animation between slides
selectedClassstring | undefined—CSS class applied in the selected state
showArrowsstring | boolean | undefinedtrueShows the navigation arrows. 'hover' — only while the pointer is over the component
tagstring | JSXComponent<any> | undefined'div'Custom HTML tag or component to render
themestring | undefined—Component theme
touchboolean | TouchHandlers | undefined—Controls swipe navigation: false turns the gestures off, an object sets your own touch handlers
transitionDurationnumber | undefined—Duration of the transition animation between slides, in milliseconds
verticalArrowsboolean | "left" | "right" | undefined—Places the navigation arrows vertically: 'left' or 'right' — the side, true — the default side
verticalDelimitersboolean | "left" | "right" | undefined—Vertical placement of the delimiters: left, right or true (left)

Events

NameTypeDescription
update:modelValue[]Fires when the active slide changes.

Slots

NameTypeDescription
default{ group: GroupProvide; }Slides. The slot props carry the group state for controlling the active slide
item{ props: CarouselDelimiterProps; item: { id: string; value: unknown; disabled: boolean | undefined; }; }Custom delimiter (navigation dot) for each slide.
next{ props: ControlProps; }Button that moves to the next slide. The slot props are ready to bind to your own button
prev{ props: ControlProps; }Button that moves to the previous slide. The slot props are ready to bind to your own button

CdsCarouselItem ​

Props

NameTypeDefaultDescription
absoluteboolean | undefined—Positions the image with position: absolute, filling its parent.
altstring | undefined—Alternative text of the image (the alt attribute).
aspectRatiostring | number | undefined—Aspect ratio of the content. For example 1.7778 (16/9) or '4/3'.
colorstring | undefined—Background color of the placeholder shown while loading.
contentClassany—CSS class applied to the content wrapper.
coverboolean | undefined—Scales the image so that it covers the whole container (object-fit: cover).
crossorigin"" | "anonymous" | "use-credentials" | undefined—Value of the crossorigin attribute.
disabledboolean | null | undefinednullDisabled state
draggableboolean | "true" | "false" | undefined—Controls whether the image can be dragged (the draggable attribute).
eagerboolean | undefined—Renders the content of the component right away. Useful when you have content that is not in the DOM but has to be indexed for SEO.
gradientstring | undefined—CSS gradient laid over the image. For example 'to top, rgba(0,0,0,.4), transparent'.
heightstring | number | undefined—Component height
imageClassany—CSS class applied to the inner <img> element.
inlineboolean | undefined—Renders the component as an inline block (inline-flex) instead of a block one.
lazySrcstring | undefined—Source of the low-quality placeholder image shown until the main one loads.
maxHeightstring | number | undefined—Maximum component height
maxWidthstring | number | undefined—Maximum component width
minHeightstring | number | undefined—Minimum component height
minWidthstring | number | undefined—Minimum component width
optionsIntersectionObserverInit | undefined{}IntersectionObserver options for lazy loading.
positionstring | undefined—Value of object-position that places the image inside the container.
referrerpolicy"origin" | "no-referrer" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | undefined—Value of the referrerpolicy attribute.
reverseTransitionstring | boolean | undefined—Transition used when the slide appears in the reverse direction. A transition component name, or false to turn the animation off
selectedClassstring | undefined—CSS class applied in the selected state
sizesstring | undefined—Value of the sizes attribute for responsive images.
srcstring | CdsImageSrcObject | undefined''Image source. A string or an object with src/srcset/lazySrc/aspect.
srcsetstring | undefined—Set of image sources for different resolutions (the srcset attribute).
themestring | undefined—Component theme
transitionstring | boolean | undefined—Transition used when the slide appears in the forward direction. A transition component name, or false to turn the animation off
valueany—Value of the component within the group
widthstring | number | undefined—Component width

Slots

NameTypeDescription
defaultanyContent shown over the image.
erroranyContent shown when the image fails to load.
placeholderanyContent shown while the image is loading.
sourcesanyExtra <source> elements for the <picture> tag.