React Native / Inputs
RadioGroup
Pick one of a few options. Every option is at least 44pt high and says its position ("2 of 3").
import { RadioGroup } from "@stylhero/native";
Example
import { useState } from "react";
import { RadioGroup } from "@stylhero/native";
function RadioGroupExample() {
const [use, setUse] = useState<"gaming" | "work">("gaming");
return (
<RadioGroup
label="Main use"
value={use}
onChange={setUse}
variant="card"
options={[
{ value: "gaming", label: "Gaming", description: "Frame rate first" },
{ value: "work", label: "Work", description: "Cores and memory first" },
]}
/>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required |
string |
- | Group label, read by screen readers. Shown above the options unless hideLabel is set. |
onChange required |
(value: T) => void |
- | |
options required |
RadioOption<T>[] |
- | |
disabled |
boolean |
- | |
error |
string |
- | Error message, read with each option. |
hideLabel |
boolean |
- | Hide the visible label when a heading right above already names the group. |
horizontal |
boolean |
- | List variant: lay the options out in a row (they wrap when space runs out). |
style |
StyleProp<ViewStyle> |
- | |
testID |
string |
- | |
value |
T |
- | |
variant |
"list" | "card" |
"list" |
"list" (default): a radio circle and text per row. "card": tiles side by side, for two to four short options with descriptions (e.g. 1080p / 1440p / 4K). They stack when the user's text size is large. |
Types
type RadioOption<T extends string> = {
value: T;
label: string;
description?: string;
disabled?: boolean;
};
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap an option | Selects it |
Accessibility
- A radio group named by
label(also withhideLabel). Each option is a radio that says it's selected and its position ("2 of 3"). variant="card"tiles stack when the text size is large.- The whole row (control, label and description) is one touch target and is read as one element.
Generated from src/components/RadioGroup.tsx. Something wrong or missing? Open an issue.