Primer

Radio group

Radio group is used to render a short list of mutually exclusive options.

import {RadioGroup} from '@primer/react-brand'

Examples

Default

RadioGroup creates a semantic container for multiple related radio inputs. Note that all radio inputs must share the same name prop to function as a group.

With caption

Use RadioGroup.Caption to provide additional context for the group.

With validation

RadioGroup.Validation can display success or error states with appropriate icons.

Inline

When space is limited, radio inputs can be arranged horizontally using the Stack component.

Component props

RadioGroup Required

NameTypeDefaultDescription
childrenReact.ReactElement[]RadioGroup components and FormControl components
idstringSets a custom id. If not provided, a unique id will be generated

RadioGroup extends the HTML fieldset element and supports all fieldset props.

RadioGroup.Label Required

NameTypeDefaultDescription
childrenstringLabel text
visuallyHiddenbooleanfalseHide label visually but keep accessible

RadioGroup.Label extends the HTML legend element and supports all legend props.

RadioGroup.Caption

NameTypeDefaultDescription
childrenstringCaption text

RadioGroup.Caption extends the span element and supports all span props.

RadioGroup.Validation

NameTypeDefaultDescription
childrenstringValidation message
variant'error'
'success'
Sets the validation state and icon

RadioGroup.Validation extends the span element and supports all span props.