react-radio-button
This react component is a div based radio button group. Simple to use and access.
How to install:
npm install react-radio-button
Example:
Usage:
; ; { superprops; thisstate = selectedValue: undefined radioOptions: value: 'CreditCard' text: 'Credit Card' value: 'DebitCard' text: 'Debit Card' ; } { this; } { return <div className="container"> <div className="row"> <div className="col-xs-12"> <h2> Welcome for the radio button example</h2> </div> <div className="col-xs-12"> <RadioButtonGroup listOfItems=thisstateradioOptions selectedItemCallback= this/> </div> <div className="col-xs-12"> <h4>Selected radio button: <i>thisstateselectedValue</i></h4> </div> </div> </div> ; }
<RadioButtonGroup listOfItems={<items>} selectedItemCallback={callbck} />
props to the listOfItems (PropTypes.array):
The items that need to appear on the radio items, is in the format (array):
javascript radioOptions: [ { value: 'CreditCard', text: 'Credit Card' }, { value: 'DebitCard', text: 'Debit Card'} ]
where,
value
is the value we get on radio button selection
text
is the display of the radio button
selectedItemCallback (PropTypes.func)
The callback that is invoked when a radio button is clicked (function):
(value) => handleSelection(value)
where,
{ //value is the selected value, like "CreditCard" or "DebitCard" this; }
Customing button colors (The default colors are shown below):
Add these to your custom css file and should be ideally changing the color for which ever color scheme you use.
With not selected state:
With selected state:
On hover, the color to change:
Once added to a custom css file (example: test.css), do import the same as:
; ;