Skip to main content

useRadioGroup

Usage

Below is a simple example of how to use the useRadioGroup hook to handle a group of Radio components.

In the getRadioProps function, the first parameter is value, which is a unique identifier for the option, or an object with props to be placed on the Radio component.

If you pass in an object, make sure it contains value.

Important: If you are going to pass props to a Radio, it is important that you pass them as objects to getRadioProps and not directly on the Radio. Otherwise, you risk overriding the functionality of useRadioGroup.

In response you get the object: