Radio

Radios are used when only one choice may be selected in a series of options.

When to use

  • When the user should see all available options.

Examples

Sizes

Small
Medium
Large

Disabled radios

Horizontal alignment

Small
Medium
Large

Error state

Overrides usage

Stateful (uncontrolled) usage

As with many of our components, there is also an uncontrolled version, StatefulRadioGroup, which manages its own state.

API

Radio props

NameTypeDefaultDescription
align
'horizontal' | 'vertical'
How to position radio buttons in the group
aria-label
string
Sets aria-label attribute.
aria-labelledby
string
Sets aria-labelledby attribute.
autoFocus
boolean
falseSet to be focused (active) on selectedchecked radio.
children
react node
Radios within the RadioGroup
className
string
Enriched style to be provided to RadioGroupRoot
containsInteractiveElement
boolean
falseIndicates the radio contains an interactive element, and the default label behavior should be prevented for child elements.
disabled
boolean
falseDisabled all radio group from being changed. To disable some of radios provide disabled flag in each of them.
intent
'default' | 'success' | 'warning' | 'error'
Defines the intent of the Radio.
labelPlacement
'top' | 'bottom' | 'left' | 'right'
rightDetermines how to position the label relative to the checkbox.
name
string
String value for the name of RadioGroup, it is used to group buttons. If missed default is random ID string.
onChange
function
Handler for change events on trigger element.
overrides
custom
Lets you customize all aspects of the component.
required
boolean
falseSet if the control is required to be checked.
size
'sm' | 'md' | 'lg'
mdThe size of the component
style
string
Enriched style to be provided to RadioGroupRoot
value
string
Passed to the input element value attribute

You can check the implementation of the component for more details.

Radio exports

You can import this module like so:

import {ALIGN} from 'baseui/radio'

It exports the following components or utility functions:

  • ALIGN
  • Radio
  • RadioGroup
  • StatefulRadioGroup
  • StyledDescription
  • StyledInput
  • StyledLabel
  • StyledRadioGroupRoot
  • StyledRadioMarkInner
  • StyledRadioMarkOuter
  • StyledRoot