Radio
Radio
Radio button is a component used for allowing a user to make a single choice among many options, while
Checkboxes are for selecting multiple options.
Single Radio Example
Pro Componentimport React from "react";import { CDBRadio, CDBContainer } from "cdbreact";export const Radio = () => {return (<CDBContainer><CDBRadiovalue="Choice 1"fill="#eb7434"colorfill="#eb7434"/><CDBRadio value="Choice 2" fill="green" colorfill="red"/><CDBRadiovalue="Choice 3"fill="#000000"colorfill="#000000"/></CDBContainer>);};
CDBRadio
Pro Componentimport React from "react";import { CDBRadioGroup, CDBContainer } from "cdbreact";export const Radio = () => {return (<CDBContainer><CDBRadioGroupfill="#eb7434"colorfill="#eb7434"answers={['Choice 1', 'Choice 2', 'Choice 3', 'Choice 4']}/></CDBContainer>);};
API
In this section you will find advanced information about the Radio component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.
Contrast Radio Import Statement
You need to import the Contrast Radio component first before using it.
import { CDBRadio, CDBRadioGroup } from "cdbreact";
API Reference: Contrast Radio Properties
The table below shows the configuration options of the CDBRadio component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBRadio className="myClass" ... /> | |
| fill | String | #455ff5 | Sets the color of the unselected radio button | <CDBRadio fill="#000000" ... /> |
| colorfill | String | Sets the color of the selected radio button | <CDBRadio colorFill="#000000" ... /> | |
| value | String | The value of the input element | <CDBRadio value="Choice1" ... /> |
API Reference: Contrast Radio Group Properties
The table below shows the configuration options of the CDBRadioGroup component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBRadioGroup className="myClass" ... /> | |
| fill | String | #455ff5 | Sets the color of the unselected radio button | <CDBRadioGroup fill="#000000" ... /> |
| colorfill | String | Sets the color of the selected radio button | <CDBRadioGroup colorFill="#000000" ... /> | |
| answers | Array | [] | The list of values of the input element | <CDBRadioGroup answers={[choice1, choice2, choice3]} ... /> |