Skip to content

CdsTagGroup

New in v4.0

A tag group turns a set of CdsTag into a toggle: the selected tag is highlighted, the value is available through v-model, and the tags that do not fit move into a horizontal scroll. Fits catalog filters, category pickers and quick period switches.

Storybook GitLab Figma
Test coverage: 100% — good coverage
API in specs
30 / 30 props, events, slots and exposed members with a test
Test cases
39 unit · 0 browser
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
13 recommendations in 11 stories measured in v4.0.0-alpha.11

If the choice should look like buttons, take CdsButtonToggle. For a choice out of a long list use CdsSelect, and for separate independent tags without selection just use CdsTag.

Variations ​

Selection ​

Give every tag a value — exactly this value lands in v-model. Without value the index of the tag in the group becomes its value. A repeated click on the selected tag clears the selection.

Multiple selection ​

The multiple prop allows selecting several tags — v-model becomes an array of values.

The max prop limits the number of selected tags: once the limit is reached, clicks on the remaining tags do not add to the selection.

Mandatory selection ​

The mandatory prop does not let you clear the last selection: a tag can only be switched. With the 'force' value the first available tag is selected automatically, even when v-model is empty.

Selection indicator ​

The filter prop adds a check icon to the selected tags — the selection reads not only from the fill. The filter-icon prop of the tag changes the icon, and the filter slot replaces it with your own markup.

Color and disabling ​

The group passes the color, active-color, disabled and filter props to its tags as defaults — there is no need to repeat them on every tag. color paints the unselected tags, active-color paints the selected one; without it the selected tag stays in the brand color so that the selection reads with any palette. disabled blocks the whole group: the selection is visible but cannot be switched. A prop set directly on a tag wins over the value of the group.

Layout ​

By default the tags stand in a single row, and the extra ones move into a horizontal scroll with arrows: the group is built on CdsSlideGroup and accepts its props — show-arrows, direction, center-active. The column prop wraps the tags into rows instead of scrolling — that way all the options are visible at once.

Guidelines ​

Scenarios ​

Catalog filter ​

A row of categories above the results is the most common job for a tag group. column shows all the categories at once, mandatory prevents ending up without a filter, and v-model gives you a ready key for the product request.

Picking several topics ​

When the values do not exclude each other, turn on multiple. max keeps the selection within reasonable bounds, filter marks the selected topics with a check, and the hint under the group explains the limit.

Switching the period ​

The group exposes the next, prev and select methods and the selected list — get them through a ref on the component. This is how tags get the back / forward arrows that walk through the periods in order.

API ​

Props

NameTypeDefaultDescription
activeColorstring | undefined—Color of the component in its active state
centerActiveboolean | undefined—Forces the active component to be aligned to the center.
colorstring | undefined—Component color
columnboolean | undefined—Lays the tags out in several rows with wrapping instead of a horizontal scroll.
contentClassany—Adds classes to the slide group container
contentStyleany—Adds inline styles to the slide group container
direction"horizontal" | "vertical" | undefined'horizontal'Switches the component between horizontal and vertical layout.
disabledboolean | null | undefinednullDisabled state
filterboolean | undefined—Shows a check icon on the selected tags (passed down to CdsTag).
mandatoryboolean | "force" | undefined—Requires at least one item to stay selected
maxnumber | undefined—Maximum number of items that can be selected
mobileboolean | null | undefinednullDetermines 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.
mobileBreakpointnumber | "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).
modelValueany—Value of the selected items of the group
multipleboolean | undefined—Allows selecting several items at once
nextIconIconValue | undefined'chevron-right'Icon for the “next” button.
prevIconIconValue | undefined'chevron-left'Icon for the “previous” button.
requiredboolean | "force" | undefined—Requires at least one item to stay selected
scrollToActiveboolean | undefinedfalseWhen true, the container scrolls the active component into view whenever it changes.
selectedClassstring | undefined'cds-tag--selected'CSS class applied in the selected state
showArrowsstring | 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.
tagstring | JSXComponent<any> | undefined'div'Custom HTML tag or component to render
themestring | undefined—Component theme

Events

NameTypeDescription
update:modelValue[value: unknown]Fires when the selected value changes.

Slots

NameTypeDescription
defaultCdsTagGroupSlotPropsTags of the group. The slot props expose the group state (selection, navigation).

Exposed

NameTypeDescription
isSelected(id: string) => booleanCheck whether a tag with the given id is selected
next() => voidSelect the next tag
prev() => voidSelect the previous tag
select(id: string, value: boolean) => voidSelect a tag by id
selectedreadonly string[]Ids of the selected tags