import * as React from "react";
import * as System from "~/components/system";
import * as Constants from "~/common/constants";
import Group from "~/components/system/Group";
import SystemPage from "~/components/system/SystemPage";
import ViewSourceLink from "~/components/system/ViewSourceLink";
import CodeBlock from "~/components/system/CodeBlock";
const RADIO_GROUP_OPTIONS = [
{
value: "1",
label: (
Option one
I want to have cake and soda for breakfast.
),
},
{
value: "2",
label: (
Option two
I want to have cake and soda for lunch.
),
},
{
value: "3",
label: (
Option three
I want to have cake and soda for dinner.
),
},
];
export default class SystemPageRadios extends React.Component {
state = {
exampleOne: "2",
};
_handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
render() {
return (
Radios
The Radio component is used when you require a user to select only one
value in a series of options.
Imports
Import React and the RadioGroup Component.
{`import * as React from 'react';
import { RadioGroup } from 'slate-react-system';`}
Usage
Define the radio group values and labels.
{`const RADIO_GROUP_OPTIONS = [
{
value: '1',
label: (
Option one
I want to have cake and soda for breakfast.
),
},
{
value: '2',
label: (
Option two
I want to have cake and soda for lunch.
),
},
{
value: '3',
label: (
Option three
I want to have cake and soda for dinner.
),
}
];`}
Declare the RadioGroup component.
{`class ExampleOne extends React.Component {
state = { ExampleOne: '2' }
_handleChange = e => this.setState(
{ [e.target.name]: e.target.value }
);
render() {
return(
)
}
}`}
Output
Accepted React Properties
onChange
),
b: "function",
c: "null",
d: "Function called upon an onChange event",
},
{
id: 2,
a: (
selected
),
b: "boolean",
c: "false",
d:
"The value that is currently selected. Can be used to assign default values as well",
},
{
id: 3,
a: (
options
),
b: "Array",
c: "[]",
d:
"An array of options, each of which has a value and a label",
},
{
id: 4,
a: "name",
b: "string",
c: "null",
d: "Input name",
},
{
id: 5,
a: "label",
b: "string",
c: "null",
d: "Label text",
},
{
id: 6,
a: "description",
b: "string",
c: "null",
d: "Description text",
},
{
id: 7,
a: "tooltip",
b: "string",
c: "null",
d: "Tooltip text",
},
],
}}
/>
);
}
}