Radio Group
React Native (Expo)
A React Native radio group drawn as cards with a springing dot, a single tab stop and arrow-key navigation on the web.
A group of mutually exclusive choices drawn as cards. The selected card takes the accent colour and its dot springs in. Only the selected radio is a tab stop, and on the web the arrow keys move the selection, skipping disabled options and wrapping at the ends, as a native radio group does. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add radio-groupManual
- Copy the code from the component tab.
- Create a file at
components/ui/radio-group.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options | RadioOption[] | - | The choices, each with a value, a label, and an optional description and disabled. |
value | string | - | The selected option's value. |
onChange | (value: string) => void | - | Called with the new value when the selection changes. |
label | string | "Options" | Spoken name of the group. |
colors | Partial<RadioGroupColors> | - | Overrides accent, border, surface, selectedSurface, label and description. |
style | StyleProp<ViewStyle> | - | Style for the group's container. |
Comments