Skip to content

CdsRadio

A radio button is one option of a mutually exclusive choice. It is not used on its own: the buttons are joined by CdsRadioGroup — it keeps the selected value, captions the set and shows the messages. The button is left with value — the value of the option, label and description — its caption and details.

Storybook GitLab Figma
Test coverage: 100% — good coverage
API in specs
29 / 29 props, events, slots and exposed members with a test
Test cases
30 unit · 0 browser · 3 planned
Known bugs
5 pinned by an it.fails test
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
no stories to check

Examples, guidelines and scenarios are on the CdsRadioGroup page. For an independent on/off option take CdsCheckbox.

API ​

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
descriptionstring | undefined—Description of the component, shown under the label
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'radio-off'Icon of the unselected state
falseValueany—Value for the false 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
labelstring | undefined—Label text of the component
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'radio-on'Icon of the selected state
trueValueany—Value for the true state.
typestring | undefined—Type of the native input element — radio or checkbox, for example
valueany—Value used when the component is selected inside a group. When it is not set, a unique identifier is used.
valueComparatorValueComparator | undefinedtrueFunction comparing the model value with the value of the control. Deep comparison by default

Slots

NameTypeDescription
default{ backgroundColorClasses: Ref<string[], string[]>; backgroundColorStyles: Ref<CSSProperties, CSSProperties>; }Default slot
description{ description: string | undefined; props: Record<string, any>; }Default slot of the CdsDescription component
inputSelectionControlSlotSlot for the default input element.
label{ label: string | undefined; props: Record<string, any>; }Default slot of the CdsLabel component