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
| Slot | Description |
|---|---|
default | The CdsSlideViewItem slides |
prev, next | Your own paging buttons; they receive props with onClick and aria-label |
additional | Content 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
| Name | Type | Default | Description |
|---|---|---|---|
continuous | boolean | undefined | — | Loops the navigation: from the last slide you move to the first one and back |
crossfade | boolean | undefined | — | Slides change with a smooth crossfade instead of a shift |
direction | "horizontal" | "vertical" | undefined | 'horizontal' | Switches the component between horizontal and vertical layout. |
disabled | boolean | null | undefined | null | Disabled state |
mandatory | boolean | "force" | undefined | — | Requires at least one item to stay selected |
max | number | undefined | — | Maximum number of items that can be selected |
modelValue | any | — | Value of the selected items of the group |
multiple | boolean | undefined | — | Allows selecting several items at once |
nextIcon | IconValue | undefined | 'chevron-right' | Icon of the button that moves to the next slide |
prevIcon | IconValue | undefined | 'chevron-left' | Icon of the button that moves to the previous slide |
required | boolean | "force" | undefined | — | Requires at least one item to stay selected |
reverse | boolean | undefined | — | Inverts the direction of the transition animation between slides |
selectedClass | string | undefined | — | CSS class applied in the selected state |
showArrows | string | boolean | undefined | — | Shows the navigation arrows. 'hover' — only while the pointer is over the component |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
theme | string | undefined | — | Component theme |
touch | boolean | TouchHandlers | undefined | — | Controls swipe navigation: false turns the gestures off, an object sets your own touch handlers |
transitionDuration | number | undefined | — | Duration of the transition animation between slides, in milliseconds |
verticalArrows | boolean | "left" | "right" | undefined | — | Places the navigation arrows vertically: 'left' or 'right' — the side, true — the default side |
Events
| Name | Type | Description |
|---|---|---|
update:modelValue | [] | Fires when the active slide changes. Passes the value of the new active slide |
Slots
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
group | GroupProvide | State of the slide group: the list of elements, the active slide and the switching methods. |
CdsSlideViewItem
Props
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | null | undefined | null | Disabled state |
eager | boolean | 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. |
reverseTransition | string | boolean | undefined | — | Transition used when the slide appears in the reverse direction. A transition component name, or false to turn the animation off |
selectedClass | string | undefined | — | CSS class applied in the selected state |
transition | string | boolean | undefined | — | Transition used when the slide appears in the forward direction. A transition component name, or false to turn the animation off |
value | any | — | Value of the component within the group |
Events
| Name | Type | Description |
|---|---|---|
group:selected | [value: { value: boolean; }] | Fires when a slide is selected inside the group. value tells whether the slide became active |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content of the slide |
Exposed
| Name | Type | Description |
|---|---|---|
groupItem | GroupItemProvide | State of the slide inside the group: whether it is selected, its value and the toggle method. |