Radio

Enables users to pick exactly one option from a group.

Radio

To implement Radio component into your project you’ll need to add the import:

import Radio from "@kiwicom/orbit-components/lib/Radio";

After adding import into your project you can use it simply like:

<Radio label="Radio" />

Props

Table below contains all types of the props available in Radio component.

NameTypeDefaultDescription
checkedbooleanfalseIf true, the Radio will be checked.
dataTeststringOptional prop for testing purposes.
idstringSet id for Radio input
disabledbooleanfalseIf true, the Radio will be set up as disabled.
hasErrorbooleanfalseIf true, the border of the Radio will turn red. See Functional specs
infoReact.NodeThe additional info about the Radio.
labelstringThe label of the Radio.
namestringThe name for the Radio.
onChangeevent => void \| PromiseFunction for handling onChange event.
reffuncProp for forwarded ref of the Radio. See Functional specs
tabIndexstring \| numberSpecifies the tab order of an element
tooltipElement<Tooltip>Optional property when you need to attach Tooltip to the Radio. See Functional specs
valuestringThe value of the Radio.
readOnlybooleanIf true, the Radio will be set up as readOnly.

Functional specs

  • ThehasError prop will be visible only when the Radio has checked or disabled prop set on false.

  • ref can be used for example auto-focus the elements immediately after render.

class Component extends React.PureComponent<Props> {
componentDidMount() {
this.ref.current && this.ref.current.focus();
}
ref: { current: React.ElementRef<*> | null } = React.createRef();
render() {
return <Radio ref={this.ref} />;
}
}
  • The tooltip property is useful when you need to visually attach Tooltip component only to the Radio’s glyph, not the label or other parts of the Radio.