Skip to content

CdsSelectionControlGroup

New in v4.0

A container for a set of selection controls: it holds the shared value, hands the nested CdsSelectionControl the type, the icons, the colors and the states, and ties them together with a single name attribute. The radio button group of the design system is built on it.

Storybook GitLab
Test coverage: 97% — good coverage
API in specs
22 / 22 props, events, slots and exposed members with a test
Test cases
36 unit · 0 browser
Known bugs
4 pinned by an it.fails test
Code coverage
97.1% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
2 recommendations in 8 stories measured in v4.0.0-alpha.11

For a ready group with a title, a description and messages take CdsRadioGroup: it is assembled from this group and the CdsInput wrapper. CdsSelectionControlGroup is needed when you build your own set of controls.

Variations ​

Shared model and type ​

The value of the selected control is held by the group: v-model is on it, every nested control only has its own value. The type, true-icon and false-icon props are handed by the group to all the controls, and the shared name attribute for the native input elements is created by the group itself — it can be overridden with the name prop.

Multiple selection ​

An array in the model turns on multiple mode: every control adds its value to it. The mode is turned on automatically — the multiple prop is needed only to set it by hand.

Direction ​

By default the controls line up in a row and split the width of the group evenly. direction="vertical" puts them in a column — handier for long captions and for sets with descriptions.

States ​

disabled blocks the whole group, readonly forbids changing the selection without changing the look, error puts every control into the error state. A single option is blocked by the disabled prop of the control itself.

Colors and icons ​

color sets the color of the selected control, base-color the color of the unselected ones, true-icon and false-icon the pair of state icons. The values apply to all the controls of the group at once.

Passing the settings through ​

The group gives its settings to the component whose name is set in defaults-target — CdsSelectionControl by default. Put the name of a ready-made control there and the group starts controlling it: that is how CdsRadioGroup hands the settings to the radio buttons.

Scenarios ​

Filtering by categories ​

An array model collects the checked categories, and the list is rebuilt on the fly through a computed. inline leaves the controls the width of their captions, so the filters go in a dense row.

Selection tiles ​

The group does not dictate the markup to the controls: in the input slot every control draws its own tile, while the group still holds the selected value and ties the native input elements together with a single name.

API ​

The props, events and slots of a single control are on the CdsSelectionControl page.

Props

NameTypeDefaultDescription
activeColorstring | undefined—Color of the component in its active state
baseColorstring | undefined—Color of the component in its inactive state
bgColorstring | undefined—Background color of the component
colorstring | undefined—Component color
defaultsTargetstring | undefined—Name of the child component the group prop values are passed to as defaults
direction"horizontal" | "vertical" | undefined'horizontal'Switches the component between horizontal and vertical layout.
disabledboolean | null | undefinednullDisabled state
errorboolean | undefined—Puts the component into the visual error state
falseIconIconValue | undefined—Icon of the unselected state
idstring | undefined—Unique identifier of the component
inlineboolean | undefined—Renders the control as an inline element — the container does not stretch to the full width
modelValueany—Value of the component (v-model). In a group it is the value of the selected control, with multiple — an array of the selected values
multipleboolean | null | undefinednullAllows selecting several values — the model becomes an array. Turns on automatically when an array is passed to modelValue
namestring | undefined—The name attribute of the native input element. In a group one name joins all the nested controls
readonlyboolean | null | undefinednullRead-only state
textColorstring | undefined—Text color of the component
themestring | undefined—Component theme
trueIconIconValue | undefined—Icon of the selected state
typestring | undefined—Type of the native input element — radio or checkbox, for example
valueComparatorValueComparator | undefinedtrueFunction comparing the model value with the value of the control. Deep comparison by default

Events

NameTypeDescription
update:modelValue[value: any]Fires when the selection inside the group changes. Passes the new value of the group

Slots

NameTypeDescription
defaultanyThe controls of the group — checkboxes or radio buttons