RadioGroup
Container for list of Radio
options
Overrides helper text
1
2
3
4
5
6
7
8
9
10
11
import React from "react"
import { Radio } from "@creation-ui/react"
export const Example = () => (
<Radio
size={"md"}
error={""}
label={"Radio Group"}
helperText={"This is helper text"}
/>
)
Code example
Notice that size
is passed from wrapper props to Radio
component
import { useState } from 'react'
import { Radio, RadioGroup, RadioGroupProps } from '@creation-ui/react'
export const RadioGroupExample = (props: RadioGroupProps) => {
const [selected, setSelected] = useState<string | undefined>()
const options = [
{ label: 'Yes', value: 'yes' },
{ label: 'No', value: 'no' },
{ label: 'Maybe', value: 'maybe' },
]
const handleClick = e => setSelected(e.target.value)
return (
<RadioGroup {...props}>
{options.map(option => (
<Radio
key={option.value}
label={option.label}
onClick={handleClick}
value={option.value}
checked={selected === option.value}
size={props.size}
/>
))}
</RadioGroup>
)
}
Component API
Prop | Default | Description |
size | md | sm | md | lg Size of the element |
label | — | React.ReactNode Label |
children | — | React.ReactNode Children to be rendered inside the component |