Skip to content

Radio Group

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.

Installation

npm i @huin-core/react-radio-group

API Reference

RadioGroup

PropTypeDescription
asChildbooleanWhen set to true, renders the component as its child element, inheriting the child's styles and behavior.
defaultValueSpecifies the initial value of the component when it is first rendered, before any user interaction or dynamic updates.
valuestringRepresents the current value or state of the component, which can be used to bind or track its data over time.
onValueChangefunctionEvent handler called when the value changes.
disabledbooleanWhen set to true, disables the component, preventing user interaction or triggering of associated actions.
namestringThe name of the piece.
requiredbooleanWhen true, indicates that the user must check the switch before the owning form can be submitted.
orientation"vertical" | "horizontal"Specifies the direction or layout of the component, determining whether it is displayed vertically or horizontally.
dir"ltr" | "rtl"The reading direction. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
loopbooleanWhen true, keyboard navigation will loop from last item to first, and vice versa.

RadioGroupItem

PropTypeDescription
asChildbooleanWhen set to true, renders the component as its child element, inheriting the child's styles and behavior.
valuestringRepresents the current value or state of the component, which can be used to bind or track its data over time.
disabledbooleanWhen set to true, disables the component, preventing user interaction or triggering of associated actions.
checkedbooleanRepresents the current state of the component, indicating whether it is enabled or selected.
namestringThe name of the piece.

RadioGroupIndicator

PropTypeDescription
asChildbooleanWhen set to true, renders the component as its child element, inheriting the child's styles and behavior.
forceMountbooleanUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries. It inherits from.

Keyboard Interactions

KeyDescription
Tab
Moves focus into the group, onto the checked item.
ArrowDown
ArrowRight
Moves to and checks the next item.
ArrowUp
ArrowLeft
Moves to and checks the previous item.