Props from Radio.Group that also appear in Radio will be overridden by Radio.Group's. In general, you should never use Radio
without a Radio.Group
.
Jackie's code dump of examples that can be cleaned up later:
const [value, setValue] = useState('female');const handleChange = (e) => {setValue(e.target.value);};<Radio.GroupmarginTop="50px"name="gender"onChange={handleChange}value={value}><Radio id="male" value="male">Male</Radio><Radio id="female" value="female">Female</Radio><Radio id="other" value="other">Other</Radio></Radio.Group><Radio.Group vertical marginTop="50px" name="colors"><Radio id="blue" value="blue">Blue</Radio><Radio color="#f00" defaultChecked id="red" value="red">Red</Radio><Radio error="warning" id="purple" value="purple">Purple</Radio><Radio disabled id="green" value="green">Green</Radio></Radio.Group><Radio.GroupdefaultValue="red2"disabledverticalmarginTop="50px"name="secondColors"><Radio id="blue2" value="blue2">Blue</Radio><Radio id="red2" value="red2">Red</Radio><Radio id="purple2" value="purple2">Purple</Radio><Radio id="green2" value="green2">Green</Radio></Radio.Group><Radio.GroupdefaultValue="blue3"error="error"verticalmarginTop="50px"name="thirdColors"><Radio id="blue3" value="blue3">Blue</Radio><Radio id="red3" value="red3">Red</Radio><Radio id="purple3" value="purple3">Purple</Radio><Radio id="green3" value="green3">Green</Radio></Radio.Group>
Common Props
Radio
includes COMMON
common props. Radio.Group
includes COMMON
, FLEX
, and BORDER
props. Read Common Props for details and API. These common props will override component props such as the color.
Radio Component Props
Prop name | Type | Default | Description |
---|---|---|---|
checked | Boolean | Whether the radio is selected or not. | |
children | Node | The label of the Radio . | |
defaultChecked | Boolean | Whether it is initially selected or not. This should not be used when checked and onChange is used or when it's Radio.Group has value and onChange set. | |
disabled | Boolean | false | Disable input |
error | default | error | warning | success | 'default' | Set the error state |
id | String | Input ID. This should always be set for accessibility purposes. | |
name | String | HTML name attribute (used for grouping) - this is unnecessary to set when using Radio.Group . | |
onChange | Func | Callback to execute on user input | |
theme | Object | Bridge Theme | Use to override default bridge theme |
value | Any | The value used to compare to see if it is selected |
Radio.Group Component Props
Prop name | Type | Default | Description |
---|---|---|---|
children | Node | These should be Radio components to be grouped together | |
defaultValue | Any | The default value (out of the children Radio s) to be selected. This should not be used when value and onChange are used | |
disabled | Boolean | false | Disable input for all children |
error | default | error | warning | success | 'default' | Set the error state for all children |
name | String | HTML name attribute for all children | |
onChange | Func | Callback to execute on user input | |
theme | Object | Bridge Theme | Use to override default bridge theme |
value | Any | The value to be currently selected | |
vertical | Boolean | false | Enable vertical grouping |