Radio

size
content
checked
disabled
import {Radio} from '@gravity-ui/uikit';

The Radio component allows the users to select a single option from a list of choices.

States

Radio can have the following states:

  • Checked: Radio is selected.
  • Disabled: Radio is unavailable for selection.
<Radio value="option 1" content="Unchecked" size="l" checked={false}/>
<Radio value="option 2" content="Checked" size="l" checked/>
<Radio value="option 3" content="Disabled" size="l" disabled/>

Size

To manage the Radio size, use the size property. The default size is m.

<Radio value="option 1" content="M Size" size="m"/>
<Radio value="option 2" content="L Size" size="l"/>

Label

You can assign a label to a Radio using the content property or provide it as a child property.

<div>
  <Radio content="Content" size="l" />
  <div
    style={{
      marginTop: 10,
    }}
  >
    <Radio size="l">
      <span>Content as children</span>
    </Radio>
  </div>
</div>

Properties

NameDescriptionTypeDefault
childrenThe content of the radio (usually, a label).ReactNode
contentThe content of the radio (alternative to children).ReactNode
disabledToggles the disabled state of the radio.booleanfalse
checkedToggles the checked state of the radio.booleanfalse
defaultCheckedSets the initial checked state when the component is mountedbooleanfalse
onUpdateFires when the radio state is changed by the user and provides the checked value as a callback argument.(checked: boolean) => void
onChangeFires when the radio state is changed by the user and provides the change event as a callback argument.Function
onFocusEvent handler to use when the radio input element receives focus.Function
onBlurEvent handler to use when the radio input element loses focus.Function
sizeSets the size of the radio.m lm
idid HTML attributestring
qadata-qa HTML attribute, used for testing.string
stylestyle HTML attributeReact.CSSProperties
classNameclass HTML attributestring
titletitle HTML attributestring
namename HTML attribute for the input elementstring
valueControl valuestring
indeterminateToggles the indeterminate state of the radio.booleanfalse
controlPropsAdditional propeties for the underlying input elementReact.InputHTMLAttributes<HTMLInputElement>
controlRefRef to the underlying input elementReact.Ref<HTMLInputElement>