Radio

There are two types of radio components that are available

  • Radio, a single Radio component
  • RadioGroup, a multiple option Radio button (group)

Usage#

Radio#
Single Radio
RadioGroup#
India
America

Code#

// Radio
const [checked, setChecked] = useState(false);
<Radio
checked={checked}
onChange={(e) => setChecked(e.target.value)}
{...props}
/>
// RadioGroup
<RadioGroup
options={[
{ label: "India", value: "IND" },
{ label: "America", value: "USA" },
]}
/>

Try RadioGroup rather than Radio, since RadioGroup having multiple options

Position#

The RadioGroup component position can be changed to either horizontal and vertical by using isHorizontal boolean prop.

India
America

Code#

<RadioGroup
options={[
{ label: "India", value: "IND" },
{ label: "America", value: "USA" },
]}
isHorizontal
/>

Disabled#

The RadioGroup and Radio component can be disabled by using the disabled prop.

India
America

Code#

<RadioGroup
options={[
{ label: "India", value: "IND" },
{ label: "America", value: "USA" },
]}
disabled
/>

Validation#

The RadioGroup component can be validated using validationText prop, if provided the validation text will be displayed

India
America
Please select a country

Code#

<RadioGroup
options={[
{ label: "India", value: "IND" },
{ label: "America", value: "USA" },
]}
isHorizontal
validationText="Please select a country"
/>

API#

Radio#

PropTypePossible valuesDefault Value
labelstringAny string value""
checkedbooleantrue and falsefalse
disabledbooleantrue and falsefalse
onChange()=>void--

RadioGroup#

PropTypePossible valuesDefault Value
options{label:'String',value:'any'}-null
isHorizontalbooleantrue and falsefalse
disabledbooleantrue and falsefalse
validationTextstringAny string value""
valueany--
onChange()=>void--

Built by Akshay 🤙