Radio group
Mutually exclusive named choices with rows or card presentation.
npx @swipeui/cli add radio-groupWhen to use it
- Choosing exactly one option where every option should be visible, such as delivery speed or plan size.
- Options with a short description under each label.
- Survey questions with a handful of answers.
- Settings where comparing options side by side helps.
When not to use it
- More than about six options. Use Select or Combobox.
- Several choices at once. Use Checkbox or Chip group.
- Two or three short options that switch a view. Use Segmented control.
- Instant on/off. Use Switch.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add radio-group- Adds
components/swipeui/ui/use-radio-group.ts,components/swipeui/ui/radio-group.tsxand 14 shared helpers. - Installs react-native-reanimated, react-native-gesture-handler, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { RadioGroup } from '@/components/swipeui/ui/radio-group';
<RadioGroup options={plans} />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
RadioGroupProps
| Prop | Type | Default | Description |
|---|---|---|---|
options | | — | Choices in reading order. |
value? | | — | Controlled selection. |
defaultValue? | | | Initial selection. |
onValueChange? | | — | Reports a new selection. |
orientation? | | | Reading axis. |
variant? | | | Compatibility alias; cards renders RadioCards. |
appearance? | | | Grouped filled surface or separate rows. |
highlight? | | | Measured row highlight. |
slideToPick? | | | Hold a row and slide to choose. |
holdDelay? | | | Hold delay in milliseconds. |
typeahead? | | | Letter navigation on the web. |
disabled? | | | Disable every row. |
haptics? | | | Per-event selection feedback. |
motion? | | | Selection and dot motion. |
messages? | | | Built-in strings. |
accessibilityLabel? | | — | Spoken group name. |
className? | | — | Root classes. |
style? | | — | Root style. |
testID? | | — | Identifier; rows append their value. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Radio group settings
| Prop | Does | Default |
|---|---|---|
| haptics | Enables selection or press feedback | true |
| motion | Overrides the app's motion feel | App feel |
| appearance | Separate rows or a grouped inset surface | rows |
| highlight | One measured gliding row highlight; snaps on resize | glide |
| slideToPick | Hold a row then slide across choices | true |
| holdDelay | Time before sliding activates, in milliseconds | 350 |
| typeahead | Jump by typed option names | true |
| orientation | Vertical rows or horizontal wrapping | vertical |
| variant | Compatibility alias; cards renders RadioCards | rows |
| disabled | Prevent every selection | false |
| messages | Translate the unavailable hint | English |
Composition and behavior
- options each have a value, label, optional description and disabled.
- orientation stacks vertically or wraps horizontally; variant is rows or cards.
- Control with value and onValueChange, or defaultValue.
Behavior and gestures
- Tap an option to select it; the dot fills in with a selection tick.
- Tapping the selected option again keeps it selected; radios can't be turned off.
- Disabled options dim and can't be picked, while the rest still work.
- The rows variant lists options plainly; the cards variant outlines each option.
Accessibility
- The set is a radio group and each option a radio with checked state.
- Descriptions are read as each option's hint.
- Name the group with accessibilityLabel, such as "Delivery speed".
- Each option is at least 44 points tall.
Motion
- Uses the
select,toggleandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The dot fills with the toggle role; the cards variant moves a selection ring with the select role.
- Reduce Motion changes selection instantly.
Performance
- Plain row frames are retained for hit-testing; animation styles live in the highlight leaf.
Notes for AI
- Give options unique values; null means nothing selected.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.