Radio
Radio options built on native inputs, grouped into one value with keyboard navigation.
c2-radio
A single radio option built on a native <input type="radio">, with its label and an optional description beside
the control. Put several in a c2-radio-group to get a single value, arrow-key navigation and a roving tab stop;
standalone radios that share a name in the same document or shadow root still uncheck each other. Theme the
control, the label and the whole row (container), which turns a radio into a selectable card. The indicator is
not tied to the ring: the dot slot swaps the inner mark, and icon / checked-icon replace the control with
any icon per state.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | Whether this option is selected. Checking one radio unchecks the others of its group. |
disabled | boolean | false | Disables this option. A disabled c2-radio-group disables every radio inside it. |
value | string | — | Value reported by the group and by the inner input. Every radio of a group needs one. |
name | string | — | Form field name. Inside a group, the group's name wins. |
required | boolean | false | Requires this standalone radio, or its containing group, to have a selected option. |
label | string | — | Label text when the default slot is empty. |
aria-label | string | — | Accessible name used when no visible label names the radio. |
aria-describedby | undefined | string | — | Id of the element that describes the radio. |
Slots
| Name | Description |
|---|---|
(default) | Label text. Falls back to the label attribute. |
description | Supporting text shown under the label. |
dot | Mark inside the ring while checked (an inline SVG, a c2-feather-* icon or a c2-mat-icon). Replaces the filled dot. |
icon | Replaces the ring with your own indicator. Shown while unchecked, and while checked too unless checked-icon is set. |
checked-icon | Indicator shown while checked, replacing the ring and dot. Without icon the default ring still shows while unchecked. |
Events
| Name | Type | Description |
|---|---|---|
change | Event | Re-dispatched from the inner input when the user checks this radio. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
control | The default circular radio indicator. |
dot | Checked-mark region containing the dot slot or fallback inside the default control. |
icon | Custom indicator shown from the icon slot. |
checked-icon | Custom indicator shown from the checked-icon slot while checked. |
label | The option label. |
description | Supporting-text region containing the description slot below the label. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-radio__container--gap | pixel | 4px | Space between the control and the text. |
--c2-radio__container--flex-direction | flex-direction-row | row | row-reverse puts the indicator after the text, e.g. a trailing check mark. |
--c2-radio__container--padding-top | padding | 0px | |
--c2-radio__container--padding-right | padding | 0px | |
--c2-radio__container--padding-bottom | padding | 0px | |
--c2-radio__container--padding-left | padding | 0px | |
--c2-radio__container--border | border | none | Set a border and padding for a card-style option. |
--c2-radio__container--border-radius | border-radius | 8px | |
--c2-radio__container--background | background | — | |
--c2-radio__container__hover--background | background | — | |
--c2-radio__container__checked--border | border | — | |
--c2-radio__container__checked--background | background | — | |
--c2-radio__control--size | pixel | 18px | |
--c2-radio__control--border-radius | border-radius | 999px | Shape of the ring and its dot; 4px gives a square control. |
--c2-radio__control--border | border | 1px solid #bcbcc6 | |
--c2-radio__control--background-color | color | transparent | |
--c2-radio__control__hover--border | border | 1px solid #a1a1aa | |
--c2-radio__control__checked--border | border | 1px solid transparent | Transparent so the fill shows through; set an accent border with a transparent fill for an outlined look. |
--c2-radio__control__checked--background-color | color | #0265dc | |
--c2-radio__control__checked__hover--background-color | color | #0154b8 | |
--c2-radio__control__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-radio__control__focus--outline-offset | pixel | 2px | |
--c2-radio__control__disabled--opacity | opacity | 0.38 | |
--c2-radio__dot--size | pixel | 8px | |
--c2-radio__dot--color | color | #ffffff | Fill of the dot, or currentColor of a slotted dot mark. |
--c2-radio__icon--size | pixel | — | Size of slotted icon / checked-icon content. Falls back to the control size. |
--c2-radio__icon--color | color | #71717a | Colour of the slotted indicator while unchecked. |
--c2-radio__icon__checked--color | color | #0265dc | Colour of the slotted indicator while checked. |
--c2-radio__state-layer--size | pixel | 32px | Touch target around the control; also the hover layer. |
--c2-radio__state-layer--border-radius | border-radius | 999px | |
--c2-radio__state-layer__hover--color | color | — | Tint of the hover layer; transparent unless set. |
--c2-radio__label--color | color | inherit | |
--c2-radio__label--font-size | font-size | inherit | |
--c2-radio__label--font-weight | font-weight | inherit | |
--c2-radio__label--line-height | line-height | inherit | |
--c2-radio__label__checked--color | color | — | |
--c2-radio__label__disabled--opacity | opacity | 0.38 | |
--c2-radio__description--color | color | #71717a | |
--c2-radio__description--font-size | font-size | 12px | |
--c2-radio__description--line-height | line-height | 1.4 | |
--c2-radio__description--margin-top | pixel | 2px | |
c2-radio-group
Groups c2-radio options into one control: a single value, one name for every option, group-level disabled,
and keyboard behaviour that matches native radios across the shadow boundary (Arrow keys move and select, only the
selected option is a tab stop). Radios may sit anywhere inside the group, wrapped in other elements. The label
and description slots name the group for assistive technology (role="radiogroup").
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | value of the checked option; empty when none is checked. Setting it checks the matching option. |
name | string | — | Form field name applied to every option. |
disabled | boolean | false | Disables every option. |
required | boolean | false | Requires one option to be selected for the form to be valid. |
orientation | RadioGroupOrientation | vertical | Lays the options out in a row instead of a column. |
aria-label | string | — | Accessible name of the radiogroup when its heading does not label it. |
Slots
| Name | Description |
|---|---|
(default) | The c2-radio options, optionally inside wrapper elements. |
label | Group heading, announced as the group's name. |
description | Supporting text under the heading. |
Events
| Name | Type | Description |
|---|---|---|
change | CustomEvent<{ value: string }> | Fired after the user selects another option. detail.value is the new value. Not fired for programmatic changes. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-radio-group--gap | pixel | 8px | Space between options. |
--c2-radio-group--align-items | align-items | flex-start | stretch makes card-style options fill the width. |
--c2-radio-group__header--gap | pixel | 2px | Space between the label and the description. |
--c2-radio-group__header--margin-bottom | pixel | 8px | Space between the header and the options. |
--c2-radio-group__header__disabled--opacity | opacity | 0.38 | |
--c2-radio-group__label--color | color | #18181b | |
--c2-radio-group__label--font-size | font-size | 14px | |
--c2-radio-group__label--font-weight | font-weight | 500 | |
--c2-radio-group__description--color | color | #71717a | |
--c2-radio-group__description--font-size | font-size | 12px | |