Radio Input
The <Radio/>
component allows to select or deselect options in a form. It provides a customizable checkbox input with various options.
- Usage
- Props
Import
import { Radio, RadioGroup } from "matro-ui";
RadioGroup
: The wrapper that provides context and logic to the components.Radio
: The radio input itself.
Usage
Loading...
Live Editor
<RadioGroup defaultValue="2"> <Radio value="1">Value 1</Radio> <Radio value="2">Value 2</Radio> </Radio>
Disabled Radio
Pass the disabled
prop to disable any radio option.
Loading...
Live Editor
<RadioGroup defaultValue="2"> <Radio value="1" disabled>Value 1</Radio> <Radio value="2" disabled>Value 2</Radio> <Radio value="3">Value 3</Radio> </Radio>
Radio sizes
Pass the font-size
to change the size of the Radio. Values can be either px
, em
, rem
or %
.
Loading...
Live Editor
<RadioGroup defaultValue="2" style={{fontSize: "21px"}}> <Radio value="1" style={{fontSize: "0.7em"}}>Value 1</Radio> <Radio value="2">Value 2</Radio> <Radio value="3">Value 3</Radio> </Radio>
Radio with custom color
You can override the color scheme of the radio to any color by providing the css variable --bg
to RadioGroup or Radio.
Loading...
Live Editor
<RadioGroup defaultValue="2" style={{"--bg": "purple"}}> <Radio value="1">Value 1</Radio> <Radio value="2" style={{"--bg": "#48b048"}}>Value 2</Radio> <Radio value="3" style={{"--bg": "#4848d7"}}>Value 3</Radio> </RadioGroup>
Props of <RadioGroup/>
:
<RadioGroup/>
:defaultValue
DescriptionThe defauilt value of the group.
Typeboolean
onChange
DescriptionCallback function triggered when the input value changes.
Typefunction
name
DescriptionThe name attribute of the input.
Typestring
style
DescriptionAdditional styling prop.
Typeobject
children
DescriptionAny possible React Children. At least one <Group/> is required.
TypeReact.FC | React.FC[] | string | number
Props of <Radio/>
:
<Radio/>
:value
DescriptionRadio input value.
Typestring | number
style
DescriptionAdditional styling prop.
Typeobject
disabled
DescriptionDisables the input.
Typeboolean
children
DescriptionLabel of the radio input.
Typestring