RadioGroup

Exactly one visible option from a short list.

  • Native host
  • In the first release
import { RadioGroup, radioGroupPrimitive } from "nitro-ui-sdk/radio-group";
HeroUI Native
RadioGroupRadio
Expo UI
RadioButton
  • RadioGroup example screen, light appearance
    Light
  • RadioGroup example screen, dark appearance
    Dark
On this page

Selects exactly one visible option from a short list of mutually exclusive choices. Use RadioGroup when all options should stay visible at once; use Select for longer lists or SegmentedControl for 2–4 compact view modes.

Anatomy

<RadioGroup.Root label="Delivery" defaultValue="daily">
  <RadioGroup.Label />
  <RadioGroup.Item value="instant" label="Instant" />
  <RadioGroup.Item value="daily" label="Daily digest">
    <RadioGroup.Indicator />
    <RadioGroup.ItemLabel />
  </RadioGroup.Item>
  <RadioGroup.Hint>Choose how often updates arrive.</RadioGroup.Hint>
</RadioGroup.Root>
Part Description
RadioGroup.Root Manages single-selection state, controller attachment, agent registration, and native group host.
RadioGroup.Label Group heading caption (hidden from duplicate screen-reader focus).
RadioGroup.Item Declares one radio option (value, label, optional disabled) rendered by the native host.
RadioGroup.Indicator Style slot controlling the radio circle tint.
RadioGroup.ItemLabel Style slot or text override for an item’s visible title.
RadioGroup.Hint Helper text attached to the group and forwarded as the native accessibility hint.

Usage

import { RadioGroup } from "nitro-ui-sdk/radio-group";

<RadioGroup.Root label="Delivery" defaultValue="daily">
  <RadioGroup.Item value="instant" label="Instant" />
  <RadioGroup.Item value="daily" label="Daily digest" />
  <RadioGroup.Item value="weekly" label="Weekly summary" />
</RadioGroup.Root>;

Variants and sizes

variant switches between "stacked" (default vertical list) and "inline" (horizontal row). size supports "sm", "md" (default), and "lg", scaling typography and minimum row height while preserving at least a 44 pt tap target.

<RadioGroup.Root label="Alignment" variant="inline" size="sm" defaultValue="left">
  <RadioGroup.Item value="left" label="Left" />
  <RadioGroup.Item value="center" label="Center" />
  <RadioGroup.Item value="right" label="Right" />
</RadioGroup.Root>

States

Disable the whole group with disabled on RadioGroup.Root, or disable individual options with disabled on RadioGroup.Item. Disabled items cannot be selected by touch, controller, or agent.

<RadioGroup.Root label="Billing" defaultValue="monthly">
  <RadioGroup.Item value="monthly" label="Monthly" />
  <RadioGroup.Item value="annual" label="Annual" disabled />
</RadioGroup.Root>

Controlled

Provide value and onValueChange to control the selected key. If the controlled value is removed from options, the group displays the first enabled fallback and requests that key on interaction until the owner accepts.

import { useState } from "react";
import { RadioGroup } from "nitro-ui-sdk/radio-group";

const [plan, setPlan] = useState("pro");

<RadioGroup.Root label="Plan" value={plan} onValueChange={setPlan}>
  <RadioGroup.Item value="starter" label="Starter" />
  <RadioGroup.Item value="pro" label="Pro" />
</RadioGroup.Root>;

Props

RadioGroup.Root

Prop Type Default Description
label string — Required visible and accessible group name.
hint string undefined Optional group helper text and accessibility hint.
options readonly RadioGroupItemProps[] Derived from Item children Declarative option array alternative to RadioGroup.Item children.
value string undefined Controlled selected option key.
defaultValue string First enabled option Initial uncontrolled selected key.
onValueChange (value: string, details: ActionDetails) => void undefined Called before selection changes.
variant "stacked" | "inline" "stacked" Vertical or horizontal layout of radio rows.
size "sm" | "md" | "lg" "md" Row height and text size scale.
disabled boolean false Disables all options in the group.
styles PartStyles<RadioGroupPart, RadioGroupVariant, RadioGroupSize, RadioGroupState> undefined Per-part style overrides.
api Controller<RadioGroupActions> undefined Imperative controller created with radioGroupPrimitive.createApi().
agentId string undefined Stable agent identity when rendered in recyclable rows.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the root container.
children ReactNode Default <Label /> + host + <Hint /> Item, Label, Hint, or custom sibling content.

RadioGroup.Item

Prop Type Default Description
value string — Unique option key.
label string — Visible and accessible option title.
disabled boolean false Disables this individual option.
part RadioGroupPart "item" Overrides the style slot for this option row.
children ReactNode undefined Optional RadioGroup.Indicator and RadioGroup.ItemLabel slot overrides.

Controller API

import { RadioGroup, radioGroupPrimitive } from "nitro-ui-sdk/radio-group";

const api = radioGroupPrimitive.createApi();
<RadioGroup.Root label="Delivery" api={api}>
  <RadioGroup.Item value="instant" label="Instant" />
  <RadioGroup.Item value="daily" label="Daily" />
</RadioGroup.Root>;
api.current?.select("daily");
Action Signature Result
select (key: string, source?: ActionSource) => ChangeStatus Selects key, returning "disabled" for disabled options or "unavailable" for unknown keys.

Styles

Style resolvers receive { tokens, variant, size, state } where state is { disabled: boolean; value: string | undefined }. Item paint properties (background, borderColor, borderWidth, cornerRadius, opacity) are forwarded directly to the native option rows.

<RadioGroup.Root
  label="Theme"
  styles={{
    indicator: ({ tokens }) => ({ text: { color: tokens.colors.success } }),
    item: ({ tokens }) => ({
      style: { background: tokens.colors.surface, cornerRadius: tokens.radius.md },
    }),
  }}
>
  <RadioGroup.Item value="ember" label="Ember" />
  <RadioGroup.Item value="slate" label="Slate" />
</RadioGroup.Root>

Accessibility

The native host exposes accessibilityContainerType = .semanticGroup on iOS (contentDescription on Android’s RadioGroup) with accessibilityLabel set to label. Each radio button announces its title, .selected / .notEnabled traits, and group hint. Touch selection plays selectionChanged() haptics; agent and API actions never vibrate.

Agent API

Action Arguments Notes
select string (option key) Selects an enabled option key from the exported options list and settles controlled updates.

Platform notes

iOS Android
Implementation Custom UIButton rows inside a semantic group container with SF Symbol indicators (circle, largecircle.fill.circle) and Dynamic Type scaling. Native RadioGroup with MaterialRadioButton rows and selectionHint delegate.
Verification Unit, type, iOS harness, and simulator screenshot verified. Written to compile; not built locally (no Android NDK on this machine).