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
version3.27.1
usageimport {useRadioGroupState} from 'react-stately'

API#


useRadioGroupState( (props: RadioGroupProps )): RadioGroupState

Interface#


Properties

NameTypeDescription
isDisabledbooleanWhether the radio group is disabled.
isReadOnlybooleanWhether the radio group is read only.
isRequiredbooleanWhether the radio group is required.
isInvalidbooleanWhether the radio group is invalid.
selectedValuestringnullundefinedThe currently selected value.
lastFocusedValuestringnullThe value of the last focused radio.

Methods

MethodDescription
setSelectedValue( (value: string )): voidSets the selected value.
setLastFocusedValue( (value: string )): voidSets the last focused value.

Example#


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