Permits user to select only one option from a list of two or more
Default and standard spacing for radio buttons.
Different sizing for radio buttons.
Custom styles for radio buttons.
Render a radio group with validation and error state
Many WCAG requirements are contextual to their implementation. To ensure that usage of this component complies with accessibility guidelines you are responsible for the following:
CdrFormGroup
should be:
label
property or slotCdrFormGroup
This component has compliance with WCAG guidelines by:
For more information, review techniques and failures for:
When using radio buttons in a list:
Radio button labels should:
This component will bind any attribute that a native HTML radio element (opens new window) accepts.
labelClass
name
string
type
N/A
default
Adds CSS class to the label for custom styles.
inputClass
name
string
type
N/A
default
Adds CSS class to the input for custom styles.
contentClass
name
string
type
N/A
default
Adds CSS class to the slot wrapper for custom styles.
name
name
string
type
N/A
default
Sets the name of the radio button. Required.
customValue
name
string, number, boolean, object, array, symbol, function
type
N/A
default
Sets the value of the radio button. Required.
modifier
name
string
type
N/A
default
Modifies the style variants for this component. Possible values: { 'hide-figure' }
size
name
string
type
'medium'
default
Sets the radio size; values can target responsive breakpoints. Breakpoint values are: xs, sm, md, and lg. Examples: { 'small' | 'medium' | 'large' | 'large@sm' }
Find more information about using Slots in the article Installing Cedar.
default
name
Sets the innerHTML for CdrRadio. This is the readable text for the <label> element.
change
name
value, event
arguments
$emit event fired on radio selection.
input
name
value
arguments
$emit event fired on radio selection.
The CdrRadio component requires v-model
to track the value of selected radios.
Following variants are available to the cdr-radio
modifier attribute:
Value | Description |
---|---|
'hide-figure' | Hides the radio button icon |
Use the hide-figure
modifier to hide the radio button itself, which leaves text label as the clickable element. Add appropriate custom styles to convey selected and unselected states.
<template>
<cdr-radio
name="example"
custom-value="model1"
v-model="model"
modifier="hide-figure"
input-class="no-box"
content-class="no-box__content"
>
Add to cart
</cdr-radio>
</template>
<style>
.no-box:checked ~ .no-box__content {
color: green;
&::after {
content: '(checked)';
}
}
</style>