useRadioGroup is a custom hook that provides all the state management logic for a group of radios.


import { useRadioGroup } from '@chakra-ui/react'

Return value#

The useRadioGroup hook returns following props

valueStringOrNumber[]The value of radio group.
namestringThe name of the radio options. All radio options must use the same name.
refanyThe ref of the radio group.
isDisabledbooleanA utility to manage disabled state.
isFocusablebooleanA utility to manage focused state.
focus() => voidA utility function to set the focus on the first enabled radio.
onChange(nextValue: EventOrValue) => voidThe onChange handler for the radio group.
setValue(state: StringOrNumber[]) => voidA function to set the value of the radio group.
getRadioProps(props?: Dict) => DictA function that takes root props and handles changes for the radio group
getRootProps(props?: Dict) => DictA function that takes radio root props and handles changes for the radio group
htmlProps{}A function that takes radio root props and handles changes for the radio group


function Example() {
function CustomRadio(props) {
const { image, ...radioProps } = props
const { state, getInputProps, getRadioProps, htmlProps, getLabelProps } =
return (
<chakra.label {...htmlProps} cursor='pointer'>
<input {...getInputProps({})} hidden />
bg={state.isChecked ? 'green.200' : 'transparent'}
<Image src={image} rounded='full' {...getLabelProps()} />
const toast = useToast()
const avatars = [
{ name: 'Kat', image: '' },
{ name: 'Kevin', image: '' },
{ name: 'Andy', image: '' },
{ name: 'Jess', image: '' },
const handleChange = (value) => {
title: `The value got changed to ${value}!`,
status: 'success',
duration: 2000,
const { value, getRadioProps, getRootProps } = useRadioGroup({
defaultValue: 'Kevin',
onChange: handleChange,
return (
<Stack {...getRootProps()}>
<Text>The selected radio is: {value}</Text>
{ => {
return (
{...getRadioProps({ value: })}

Using isDisabled and isFocusable#

When providing the hook with the isDisabled and/or isFocusable props, this values also need to be returned and passed to the radio inputs.

This is different than simply passing them as props to the RadioGroup component because the component has access to context to supply the values to the radio inputs.

Below is an example with isDisabled being passed to the hook and used with the Radio component. If needed, this custom component can than be controllable by a parent, which would supply the logic to determine if the inputs need to be disabled.

function CustomRadioGroup(props) {
const { options, } = props
const { getRootProps, getRadioProps, isDisabled } = useRadioGroup({,
const group = getRootProps()
return (
<HStack {}>
{ => {
const radio = getRadioProps({ value })
return (
<Radio isDisabled={isDisabled} key={value} {}>
function Parent() {
const [isDisabled, setIsDisabled] = useState(true)
// Some logic to handle the disabled state
return (
{/* Any components above */}
options={['react', 'vue', 'svelte']}
{/* Any components below */}
render(<Parent />)


The useRadioGroup hook accepts an object with the following properties:

Edit this page on GitHub

Proudly made inNigeria by Segun Adebayo

Deployed by Vercel