Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

RadioGroup

  • Stable
  • WCAG 2.2 evidence
  • RTL

One choice from a short list of mutually exclusive options: a legend with an optional required asterisk and helper text, the options as RadioField rows or RadioCards, and an error with an icon. Built on React Aria RadioGroup: a named role="radiogroup" that is one Tab stop; arrow keys move to and select the next option (Left and Right are mirrored in right-to-left locales when horizontal), Space selects (WCAG 2.1.1, 4.1.2). The helper and the error are linked to every option with aria-describedby (1.3.1, 3.3.1); the error is text with an icon (1.4.1). Consumer duties: legend and option wording (parallel grammar), error wording; more than six options belong in a Select, and a binary on/off choice in a Switch.

import { RadioGroup } from "@nexera-ui/react";
Loading example…
4
examples
23
props
6
live controls
1
platform
8
WCAG criteria
9
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
children
description
isDisabled
isReadOnly
isRequired
isInvalid
Generated code
import { RadioGroup } from "@nexera-ui/react";

<RadioGroup />

Examples 3

The same examples as Storybook, rendered live. Open Code to copy one.

Cards

Cards: RadioCard options, 12 px apart.

Loading example…

Horizontal

Figma Orientation=Horizontal: the options sit in a row and wrap onto new rows when the container is narrow.

Loading example…

Right to left

Right-to-left: the legend and options align right; Left and Right arrows are mirrored in horizontal groups.

Loading example…

Props 23

Press "Try it" on a card to load that prop into the playground.

23 props shown

children*Nexera
ReactNode

The options: RadioFields, RadioCards or bare Radios, each with a value.

Default –
descriptionNexera
ReactNode

Helper text under the legend. Linked to the group and to every option with aria-describedby. Shown when provided.

Default –
errorMessageNexera
ReactNode | ((validation: ValidationResult) => ReactNode)

Error under the options with an icon. Shown while the group is invalid (isInvalid, validate, or native isRequired validation on submit); defaults to the validation message. Write how to fix it ("Choose who can see your birthday.").

Default –
typeNexera
"list" | "card"

Option layout: list for RadioField rows (24 px apart when horizontal), card for RadioCards (12 px apart, 232 px wide when horizontal). The options themselves come from children.

Default list
classNameNexera
string

Extra classes for the root, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style of the root.

Default –
labelNexera
VisibleContent

Visible legend above the options. Names the group; wraps. No visible legend.

Default –
aria-labelNexera
string

Overrides the name given by label. Avoid: the name must contain the visible text (WCAG 2.5.3). Accessible name of the group. Translate it. Accessible name; aria-labelledby wins when both are set.

Default –
aria-labelledbyNexera
string

Id(s) of element(s) that name the group instead of label. Id(s) of element(s) that name the group; wins over aria-label. Id(s) of the visible element(s) that name the group.

Default –
validationBehaviorReact Aria
"native" | "aria"

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Default 'native'
nameReact Aria
string

The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).

Default –
orientationReact Aria
"horizontal" | "vertical"

The axis the Radio Button(s) should align with.

Default 'vertical'
valueReact Aria
string | null

The current value (controlled).

Default –
defaultValueReact Aria
string | null

The default value (uncontrolled).

Default –
onChangeReact Aria
(value: string) => void

Handler that is called when the value changes.

Default –
isDisabledReact Aria
boolean

Whether the input is disabled.

Default –
isReadOnlyReact Aria
boolean

Whether the input can be selected but not changed by the user.

Default –
isRequiredReact Aria
boolean

Whether user input is required on the input before form submission.

Default –
isInvalidReact Aria
boolean

Whether the input value is invalid.

Default –
validateReact Aria
(value: string) => true | ValidationError | null

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

Default –
formReact Aria
string

The <form> element to associate the input with. The value of this attribute must be the id of a <form> in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).

Default –
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

6 direct · 2 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 3.3.1Error IdentificationLevel A · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<RadioGroup className="shadow-sm" />

Used in blocks

Related components