RadioGroupField renders all options and reports the selected string value.
Usage
import { useState } from 'react';
import { RadioGroupField } from '@amisi-mobile-starter/ui';
const options = [
{ label: 'Monthly', value: 'monthly' },
{ label: 'Yearly', value: 'yearly' },
];
export const BillingCycleField = () => {
const [cycle, setCycle] = useState('monthly');
return (
<RadioGroupField
label="Billing cycle"
value={cycle}
options={options}
onValueChange={setCycle}
/>
);
};
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | undefined | Group label. |
value | string | Required | Controlled selected value. |
options | Array<{ label: string; value: string }> | Required | Available options. |
onValueChange | (nextValue: string) => void | Required | Runs when an option is pressed. |
helperText | string | undefined | Supporting text shown when there is no error. |
error | string | undefined | Error shown instead of helper text. |
optionProps | Omit<PressableProps, 'onPress'> | undefined | Native props spread onto every option. |
RadioGroupField also accepts React Native ViewProps.