Skip to content

CdsSlideView

A slide view shows one slide out of a set and switches them with a shift animation: arrows, swipes and v-model page forward and backward. It is the base for carousels and step-by-step interfaces — CdsCarousel is built on the slide view.

Storybook GitLab
Test coverage: no tests

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

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

For a carousel of images with dot delimiters and autoplay take the ready CdsCarousel, for sections with a navigation bar take CdsTabs, and for a strip where several elements are visible at once take CdsSlideGroup.

Anatomy ​

The container shows one active CdsSlideViewItem slide, and the arrows at the edges page to the neighboring ones — they are turned on by the show-arrows prop. v-model holds the index of the active slide — or the value from the value prop of the slide, if it is set.

Variations ​

Arrows ​

By default there are no arrows — the slides are paged with a swipe on touch devices or programmatically through v-model. The show-arrows prop turns the arrows on: true shows them at all times, "hover" only on hover over the slide. Keyboard navigation comes together with the arrows. The swipe is turned off with :touch="false", and the icons of the arrows are changed with the prev-icon and next-icon props.

Vertical arrows ​

The vertical-arrows prop gathers the arrows turned on by show-arrows into a column at the edge of the slide: true or 'left' puts them on the left, 'right' on the right.

Continuous paging ​

The continuous prop closes the slides into a ring: the first one follows the last. Without it the matching arrow is hidden on the edge slides.

Direction ​

The direction="vertical" prop moves the slides vertically — the navigation keys change together with the animation: ↑ / ↓ work instead of ← / →.

Transitions ​

The crossfade prop replaces the shift with a soft dissolve — a good fit when the slides are not lined up in a sequence. On a single CdsSlideViewItem the animation is configured with the transition and reverse-transition props: the name of your own transition animation or false to turn it off. The content of a slide is rendered on the first show; the eager prop renders it right away — useful for SEO.

Slots ​

SlotDescription
defaultThe CdsSlideViewItem slides
prev, nextYour own paging buttons; they receive props with onClick and aria-label
additionalContent after the slides: indicators, a counter, captions

The additional slot receives a group with the selection methods — but an outer v-model is usually enough, as in the demo with the dot indicators.

Guidelines ​

Scenarios ​

A step-by-step form ​

The steps of a questionnaire are switched with buttons through v-model: the arrows stay off and the swipes are muted with :touch="false" — the only way to move is "Back" and "Next". The height of the container animates to the content of the active step automatically.

Customer testimonials ​

The quotes are not lined up in a sequence, so crossfade replaces the shift. The arrows appear on hover (show-arrows="hover"), the position is shown by a counter in the additional slot, and continuous pages the testimonials in a loop.

An events feed ​

A compact widget with vertical paging: direction="vertical" moves the events from the bottom up, and vertical-arrows="right" gathers the arrows into a column at the right edge.

API ​

CdsSlideView ​

Props

NameTypeDefaultDescription
continuousboolean | undefined—Loops 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
direction"horizontal" | "vertical" | undefined'horizontal'Switches the component between horizontal and vertical layout.
disabledboolean | null | undefinednullDisabled state
mandatoryboolean | "force" | undefined—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
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 | undefined—Shows 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

Events

NameTypeDescription
update:modelValue[]Fires when the active slide changes. Passes the value of the new active slide

Slots

NameTypeDescription
additional{ group: GroupProvide; }Extra content above the slides — indicator dots or your own navigation, for example
default{ group: GroupProvide; }Slides. The slot props carry the group state for controlling the active 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

Exposed

NameTypeDescription
groupGroupProvideState of the slide group: the list of elements, the active slide and the switching methods.

CdsSlideViewItem ​

Props

NameTypeDefaultDescription
disabledboolean | null | undefinednullDisabled state
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.
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
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

Events

NameTypeDescription
group:selected[value: { value: boolean; }]Fires when a slide is selected inside the group. value tells whether the slide became active

Slots

NameTypeDescription
defaultanyContent of the slide

Exposed

NameTypeDescription
groupItemGroupItemProvideState of the slide inside the group: whether it is selected, its value and the toggle method.