If you answer yes, we store and analyse information that helps us improve the website. You can change your choice at any time at the bottom of the page. More about what we store and why.

We also store necessary information that cannot be opted out of. This makes the website work and keeps it secure.

Skip to main content

What are you looking for?

Try searching for…

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:

Edit this page on github.com (opens in a new tab)