For a bar of sections take the ready CdsTabs, for picking tags take CdsTagGroup, and to page through slides one by one take CdsSlideView.
Anatomy
Arrow buttons sit at the edges of the container, and the strip of elements scrolls between them. The arrows appear only when the strip does not fit into the container, and they page it by the width of the visible area.
Variations
Scrolling and arrows
By default the arrows appear on a desktop when the elements do not fit into the container; on mobile the strip is scrolled with a finger without arrows. The show-arrows prop changes this behavior: true shows the arrows on overflow and on mobile, desktop and mobile always show them on the matching devices, always always shows them, never never does.
Selecting elements
Wrap the elements into CdsSlideGroupItem and the group starts driving the selection: v-model holds the value of the selected element from its value prop. CdsSlideGroupItem itself renders nothing — its slot receives isSelected and toggle, and how to show the selected state is up to you. The mandatory prop forbids clearing the last selection.
The multiple prop allows selecting several elements — v-model becomes an array, and max limits the number of selected ones.
The active element in the center
When the selection changes, the strip scrolls to the active element itself — that is the job of scroll-to-active, which is on by default. The center-active prop additionally keeps the active element in the center of the container.
Vertical group
The direction="vertical" prop turns the strip into a column — limit its height with max-height on the group itself.
Slots
| Slot | Description |
|---|---|
default | The elements of the strip, usually CdsSlideGroupItem |
prev | Your own content for the "back" button instead of the arrow |
next | Your own content for the "forward" button instead of the arrow |
All the slots receive the prev, next, select and isSelected methods. The click on the area of an arrow is handled by the group itself, so it is enough to put the visuals only into prev / next. The icons of the default arrows are changed without slots — with the prev-icon and next-icon props.
Guidelines
Scenarios
Booking an appointment
Two slide groups with a selection: the strip of days with center-active keeps the selected date in the center, and the strip of times is more compact — with size="sm" buttons. Both lists use mandatory: a booking always has a selected date and time.
A strip of documents
The slide group works without a selection too — as a regular scrollable strip. The cards go straight into the default slot without CdsSlideGroupItem, and the arrows page the strip by the width of the visible area.
A formatting bar
A toolbar inside a narrow container: icon buttons with aria-label, multiple allows turning several formats on at once, and the show-arrows="always" arrows page through the tools that did not fit.
API
CdsSlideGroup
Props
| Name | Type | Default | Description |
|---|---|---|---|
centerActive | boolean | undefined | — | Forces the active component to be aligned to the center. |
contentClass | any | — | Adds classes to the slide group container |
contentStyle | any | — | Adds inline styles to the slide group container |
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 |
mobile | boolean | null | undefined | null | Determines the display mode of the component: true renders it in mobile mode, false in desktop mode, null makes the mode depend on the current breakpoint. |
mobileBreakpoint | number | "xs" | "sm" | "md" | "lg" | "xl" | undefined | — | Sets the breakpoint at which the component switches to mobile mode. Accepts a number (for example, 600) or the name of a predefined breakpoint (xs, sm, md, lg, xl). |
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 for the “next” button. |
prevIcon | IconValue | undefined | 'chevron-left' | Icon for the “previous” button. |
required | boolean | "force" | undefined | — | Requires at least one item to stay selected |
scrollToActive | boolean | undefined | true | When true, the container scrolls the active component into view whenever it changes. |
selectedClass | string | undefined | 'cds-slide-group-item--active' | CSS class applied in the selected state |
showArrows | string | boolean | undefined | — | Changes how the arrows are shown. By default the arrows appear on desktop devices when the container overflows and stay hidden on mobile devices. true also shows them on mobile on overflow, desktop always shows them on desktop, mobile always on mobile, always on both, and never disables the arrows. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
Slots
| Name | Type | Description |
|---|---|---|
default | SlideGroupSlot | Slot for the CdsSlideGroupItem components |
next | SlideGroupSlot | Slot for the "next" button. |
prev | SlideGroupSlot | Slot for the "previous" button. |
Exposed
| Name | Type | Description |
|---|---|---|
focus | (location?: "next" | "prev" | "first" | "last" | undefined) => void | Focuses the component |
hasNext | boolean | Returns true if there are elements after the current index. |
hasPrev | boolean | Returns true if there are elements before the current index. |
scrollOffset | number | Returns the scroll offset of the element |
scrollTo | (location: "next" | "prev") => void | Scrolls to the element by its index |
selected | readonly string[] | Returns the index of the selected element |
CdsSlideGroupItem
Props
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | null | undefined | null | Disabled state |
selectedClass | string | undefined | — | CSS class applied in the selected state |
value | any | — | Value of the component within the group |
Events
| Name | Type | Description |
|---|---|---|
group:selected | [value: { value: boolean; }] | Fires when an element is selected inside the group. |
Slots
| Name | Type | Description |
|---|---|---|
default | { isSelected: boolean; select: (value: boolean) => void; toggle: () => void; selectedClass: false | (string | undefined)[]; } | Slot for the content |