import { Radio, Text, useRadioGroup } from "@vortexlabs/vortex-native";
const DeliverySummary = () => {
const group = useRadioGroup();
if (!group) return null;
return <Text>Delivery: {group.value ?? "Choose a method"}</Text>;
};
export const Example = () => (
<Radio.Group ariaLabel="Delivery method" defaultValue="standard">
<Radio.GroupLabel>Delivery method</Radio.GroupLabel>
<Radio.Item value="standard">Standard</Radio.Item>
<Radio.Item value="express">Express</Radio.Item>
<DeliverySummary />
</Radio.Group>
);Features
- Reads the closest group's selection and shared state.
- Updates when the group value changes.
- Returns
nulloutside the group.
Group Context
Call useRadioGroup() without arguments from a descendant of Radio.Group. Inside the group, value is null until an option is selected.
A component that renders the group must put the hook in a child to read its selection. Use Radio.Item for selectable controls. It handles presses and announces the checked state.