Radio
The Radio component provides a way for the end user to select between multiple options.

Props

Name
Type
Description
Required
Default
disabled
boolean
Prevents the radio group from interaction.
null
options
array[string]
List of options rendered to the end user as individual radio inputs.
onSelect
function
Executes the provided function when the end user clicks a certain radio input.
selected
number
State value associated with the radio group.
validationError
string
When not '' or undefined, outlines the input in red and renders the provided text in red beneath the input.
null

Examples

Radio group with 3 options and a validation error
Javascript
React
1
import { whisper } from '@oliveai/ldk';
2
import {
3
WhisperComponentType,
4
} from '@oliveai/ldk/dist/whisper/types';
5
6
export const radioWhisper = async () => {
7
await whisper.create({
8
label: 'Radio Group',
9
components: [
10
{
11
type: WhisperComponentType.RadioGroup,
12
onSelect: (error, value) => {
13
console.log('onSelect', error, value)
14
},
15
options: [
16
'Radio One',
17
'Radio Two',
18
'Radio Three',
19
],
20
selected: 0,
21
validationError: 'Validation Error',
22
},
23
],
24
});
25
}
26
Copied!
1
import * as React from 'react';
2
import '@oliveai/ldk';
3
import * as ReactWhisper from '@oliveai/ldk/dist/whisper/react/renderer';
4
5
const TestRadioGroup = () => {
6
const [selected, setSelected] = React.useState(0);
7
8
return (
9
<oh-whisper label="Radio Group" onClose={() => {}}>
10
<oh-radio-group
11
onSelect={(error, value) => console.log('onSelect', error, value)}
12
options={[
13
'Radio One',
14
'Radio Two',
15
'Radio Three',
16
]}
17
selected={selected}
18
validationError="Validation Error"
19
/>
20
</oh-whisper>
21
);
22
};
23
24
ReactWhisper.renderNewWhisper(<TestRadioGroup />);
Copied!
Copy link