<cs-radio>
StableFormsSince 0.1

Radios represent a single option within a mutually exclusive set. Use them inside a radio group when users must pick exactly one choice from a small list.

This component must be used as a child of <cs-radio-group>. Please see the Radio Group docs to see examples of this component in action.

Off Wi-Fi Everything

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/radio/radio.js';
import './cornerstone/components/radio/radio.js';
import CsRadio from '@cruglobal/cornerstone-components/react/radio/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The radio's label.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
appearanceappearanceThe radio's visual appearance.'default' | 'button''default'Yes
disableddisabledDisables the radio.booleanfalse
formBy default, form controls are associated with the nearest containing <form> element. This attribute allows you to place the form control outside of a form and associate it with the form that has this id. The form must be in the same document or shadow root for this to work.HTMLFormElement | null
namenameThe name of the input, submitted as a name/value pair with form data.string | nullnullYes
sizesizeThe radio's size. When used inside a radio group, the size will be determined by the radio group's size, which will override this attribute.'xs' | 's' | 'm' | 'l' | 'xl'Yes
validationTargetOverride this to change where constraint validation popups are anchored.undefined | HTMLElement
validatorsValidators are static because they have observedAttributes, essentially attributes to "watch" for changes. Whenever these attributes change, we want to be notified and update the validator.Validator[][]
valuevalueThe radio's value. When selected, the radio group will receive this value.stringYes

Methods

Learn more about methods.

NameDescriptionArguments
formStateRestoreCallback()Called when the browser is trying to restore element’s state to state in which case reason is "restore", or when the browser is trying to fulfill autofill on behalf of user in which case reason is "autocomplete". In the case of "restore", state is a string, File, or FormData object previously set as the second argument to setFormValue.state: string | File | FormData | null, reason: 'autocomplete' | 'restore'
resetValidity()Reset validity is a way of removing manual custom errors and native validation.
setCustomValidity()Do not use this when creating a "Validator". This is intended for end users of components. We track manually defined custom errors so we don't clear them on accident in our validators.message: string

Events

Learn more about events.

NameDescription
blurEmitted when the control loses focus.
focusEmitted when the control gains focus.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--checked-icon-colorThe color of the checked icon.
--checked-icon-scaleThe size of the checked icon relative to the radio.

Custom States

Learn more about custom states.

NameDescriptionCSS selector
checkedApplied when the control is checked.:state(checked)
disabledApplied when the control is disabled.:state(disabled)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
checked-iconThe checked icon.::part(checked-icon)
controlThe circular container that wraps the radio's checked state.::part(control)
labelThe container that wraps the radio's label.::part(label)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.