• /
  • Log in

RadioGroup

A group of <Radio> buttons. The <Radio> buttons may either be direct children or descendants of the radio group. <Radio> buttons inside a radio group must have a unique value assigned.

Once a radio group is established, selecting any <Radio> in that group automatically deselects any currently-selected <Radio> in the group.

Note: Setting value will override defaultValue as it puts the RadioGroup into a controlled state. value will not override Radio components that have checked set, as RadioGroup will take control of uncontrolled Radio components and can't override controlled ones.

The onChange event handler for RadioGroup will fire after any onChange event handler set on individual Radio components. However, it is highly recommended to only set one event handler for the whole group in a controlled RadioGroup.

Usage

import { RadioGroup } from 'nr1'

Examples

Props

childrennode

Content of the RadioGroup.

classNamestring

Appends class names to the component.

defaultValueany

Default value of the radio group. The <Radio> with the matching value will be selected.

Useful when you don't want to use a controlled component.

descriptionstring

Message with instructions on how to fill the form field.

infostring

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

invalidboolean|string

When true, sets the field in an invalid state, in order to notify the user attention is needed over this particular field. This property can be a boolean field or a string. When it is a string, as well as the invalid state being shown, the text will be shown below.

labelstring

Text to display as label.

labelInlineboolean

Display the label inline the form control.

Use only when the component is not inside a Form. In that case set layoutType to Form.LAYOUT_TYPE.SPLIT in the Form component.

onChangefunction

Callback which is fired when the radio group value changes (a <Radio> in the group is selected).

function (
event: react.ChangeEvent, //

Event source of the callback.

value: any //

The value of the selected radio button.

)
requiredboolean
DEFAULT
false

If true, denotes the form field as required.

styleobject

Inline style for custom styling.

testIdstring

Adds a data-test-id attribute.

Use it to target the component in unit and e2e tests.

valueany

Value of the radio group. The radio button with the matching value will be selected.

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

Create issueEdit page
Copyright © 2021 New Relic Inc.