useRadioGroupState

Provides state management for a radio group component. Provides a name for the group, and manages selection and focus state.

installyarn add @react-stately/radio
version3.0.0-rc.2
usageimport {useRadioGroupState} from '@react-stately/radio'

API#


useRadioGroupState(props: RadioGroupProps): RadioGroupState

Interface#


NameTypeDescription
namestringThe name for the group, used for native form submission.
selectedValuestringundefinedThe currently selected value.
setSelectedValue(value: string) => voidSets the selected value.
focusableRadiostringundefinedThe last focused radio.
setFocusableRadio(value: string) => voidSets the last focused radio.

Example#


See the docs for useRadioGroup in react-aria for an example of useRadioGroupState.