CxJS

Radio

import { Radio } from 'cx/widgets'; Copied

Radio buttons are used for making a single selection within a limited number of options. All radios in a group share the same value binding, and each has a unique option. When clicked, the radio’s option value is written to value.

<div style="display: flex; flex-direction: column; gap: 8px">
  <Radio value={m.size} option="small" text="Small" default />
  <Radio value={m.size} option="medium" text="Medium" />
  <Radio value={m.size} option="large" text="Large" />
  <Radio value={m.size} option="disabled" text="Disabled Option" disabled />
</div>

Configuration

Core Properties

PropertyTypeDefaultDescription
valueanySelected value shared by all radios in a group
selectionanyAlias for value
optionanyValue written to value when this radio is selected
textstringText displayed next to the radio button
labelstringLabel displayed before the radio button
disabledbooleanfalseDisables the radio button
readOnlybooleanfalseMakes the radio button read-only
requiredbooleanfalseMarks the field as required
defaultbooleanfalseAuto-select this radio if value is undefined
viewModebooleanfalseDisplay as plain text instead of interactive radio
autoFocusbooleanfalseAutomatically focus the field on mount

Appearance

PropertyTypeDefaultDescription
nativebooleanfalseUse native HTML radio instead of styled version
inputStyleobjectCSS styles for the radio element
emptyTextstringText shown in view mode when no option is selected
tooltipstringTooltip text or configuration

Callbacks

PropertyTypeDescription
onValidatefunctionCustom validation function returning error or undefined