• /
  • Log in
  • Free account

Radio

When a user can choose only one of the options provided

The radio button state can be controlled through the checked property. If the checked prop is not set then the radio button will manage its own state.

You can listen to the radio button events through the onClick or the onChange props.

Usage

import { Radio } from 'nr1'

Examples

Basic

ReferenceError: Radio is not defined

Controlled component

Props

checkedboolean

If true, the radio button is checked.

If defined, it turns the input into a controlled component.

classNamestring

Appends class names to the component.

Should be used only for positioning and spacing purposes.

disabledboolean
DEFAULT
false

If true, the radio button is not available for interaction.

infostring

Additional information can be displayed in an info tooltip next to the Label.

labelstring

Text to display as label.

onChangefunction

Callback fired any time the selected state of the radio button changes.

function (
event: React.ChangeEvent<HTMLInputElement>, //

Event source of the callback.

value: any //

The value of the radio button.

) => undefined
onClickfunction

Callback fired any time the radio button is clicked.

function (
event: React.MouseEvent<HTMLInputElement> //

Event source of the callback.

) => undefined
spacingTypeenum[]

Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like margin or padding. To omit a value, use SPACING_TYPE.OMIT.

<Array of
<One of
Radio.SPACING_TYPE.EXTRA_LARGE,
Radio.SPACING_TYPE.LARGE,
Radio.SPACING_TYPE.MEDIUM,
Radio.SPACING_TYPE.NONE,
Radio.SPACING_TYPE.OMIT,
Radio.SPACING_TYPE.SMALL,
>
>
styleobject

Inline style for custom styling.

Should be used only for positioning and spacing purposes.

testIdstring

Adds a data-test-id.

Used to target the component in unit and e2e testing.

valuestring

The value of the component. Used by the <RadioGroup/> to identify the selected radio button.

Methods

Radio.render

function () => undefined
Create issueEdit page
Copyright © 2021 New Relic Inc.