Usage
Controlled
States
Change icon
Change icon color
Disabled state
Pointer cursor
By default, radio input and label have cursor: default
(same as native input[type="radio"]
).
To change cursor to pointer, set cursorType
on theme:
Radio with tooltip
You can change target element to which tooltip is attached with refProp
:
- If
refProp
is not set, the tooltip is attached to the checkbox input - If
refProp="rootRef"
is set, the tooltip is attached to the root element (contains label, input and other elements)
Add props to the root element
All props passed to the component are forwarded to the input element. If you need to add props to the root element, use wrapperProps
. In the following example:
data-testid="wrapper"
is added to the root elementdata-testid="input"
is added to the input element
Radio.Group component
This is anonymous
Controlled Radio.Group
Radio.Indicator
Radio.Indicator
looks exactly the same as Radio
component, but it does not
have any semantic meaning, it's just a visual representation of radio state. You
can use it in any place where you need to display radio state without any interaction
related to the indicator. For example, it is useful in cards based on buttons, trees, etc.
Note that Radio.Indicator
cannot be focused or selected with keyboard. It is not
accessible and should not be used as a replacement for Radio
component.
Radio.Card component
Radio.Card
component can be used as a replacement for Radio
to build custom
cards/buttons/other things that work as radios. The root element of the component
has role="radio"
attribute, it is accessible by default and supports the same
keyboard interactions as input[type="radio"]
.
You can use Radio.Card
with Radio.Group
the same way as Radio
component:
Choose a package that you will need in your application
CurrentValue: –
Get element ref
Styles API
Radio
supports Styles API, you can add styles to any inner element of the component withclassNames
prop. Follow Styles API documentation to learn more.
Radio description
Radio error
Component Styles API
Hover over selectors to highlight corresponding elements
Accessibility
Set aria-label
or label
prop to make the radio accessible: