suiss/uim · React Native Component

Radio Group

A set of radio buttons where only one option can be selected at a time.

Radio Group is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Radio Group on iOS in light mode

RadioGroup is a View with the radiogroup role that holds the selected value. Each RadioGroupItem is a small round Pressable with the radio role; when checked it fills with the accent color and shows a dot. Items have an enlarged hit area so they are easy to press.

Installation

$ pnpm dlx @esuiss/uim@latest add radio-group

Manual

  1. Install the dependencies:
npx expo install cn
  1. Add the pieces it builds on: the primitives components/primitives/radio.tsx, components/primitives/radio-group.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/radio-group.tsx:

uniwind/components/ui/radio-group.tsx
import { cn } from "cn"
import { View } from "react-native"
import * as RadioPrimitive from "@/components/primitives/radio"
import {
  RadioGroup as RadioGroupPrimitive,
  type RadioGroupProps,
} from "@/components/primitives/radio-group"
import { resolveClassName } from "@/components/primitives/use-render"

const HIT_SLOP = { top: 8, bottom: 8, left: 12, right: 12 }

function RadioGroup<Value = string>({
  className,
  ...props
}: RadioGroupProps<Value>) {
  return (
  1. Update the import paths to match your project.

Usage

import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroupDemo />

Give every RadioGroupItem a unique value. Control the group with value and onValueChange(value, details), or leave it uncontrolled with defaultValue. Values are generic, so they can be strings or other types.

Put a Label next to each item and link it through nativeID and accessibilityLabelledBy. Set disabled on the group to disable all items, or on a single item. Set invalid on items to show the danger border.

Examples

With descriptions

Options with a label and a line of description each.

iOS
Radio Group (with descriptions) on iOS in light mode

Disabled item

A group with one disabled option.

iOS
Radio Group (disabled item) on iOS in light mode

Disabled

A fully disabled group.

iOS
Radio Group (disabled) on iOS in light mode

Invalid

Items with the invalid border.

iOS
Radio Group (invalid) on iOS in light mode

API Reference

RadioGroup

The container that holds the selected value.

ExtendsRadioGroupProps<Value>

RadioGroupItem

A single radio button with its checked indicator.

ExtendsRadioPrimitive.RootProps<Value>
PropType
About
Shows a danger border while unchecked.
Type
boolean
Default
—

Accessibility

  • The group has the radiogroup role and reports disabled in accessibilityState.
  • Each item has the radio role and reports checked and disabled in accessibilityState.
  • The indicator is hidden from screen readers; label each item with a linked Label or an accessibilityLabel.

Notes

  • Selecting an item triggers a selection haptic when a haptics adapter is provided through HapticsContext.
  • Uses the bg-accent, bg-accent-disabled, bg-control-disabled, bg-on-accent and border-danger tokens.
  • Light and dark colors follow the system appearance; in dark mode unchecked items drop the border and shadow.