RadioGroup

A radio group with one selected value.

Pass Radio elements as children. onChange returns the selected value. label, description, and errorMessage add a group heading, a hint, and error text. Items keep their own disabled, size, and name.

Live example

Group label

Example controls

Usage

import { Radio, RadioGroup } from '@prosazhin/pbcomponents';

<RadioGroup
  label='Options'
  defaultValue='One'
  onChange={(value) => console.log(value)}
>
  {['One', 'Two', 'Three', 'Four', 'Five'].map((item) => (
    <Radio
      key={item}
      value={item}
    >
      {item}
    </Radio>
  ))}
</RadioGroup>;

Component API

PropType / variantsPurposeDefault
childrenRadio[]Radio choices; items keep their own disabled, size and name.—
size's' | 'm's · mComponent size.—
labelReactNodeGroup heading (legend).—
descriptionReactNodeHint below the group heading.—
errorMessageReactNodeError text below the group; linked to it via aria-describedby.—
namestringShared name of the native inputs.—
disabledbooleanDisables interaction.false
valuestringSelected value.—
defaultValuestringInitial value when uncontrolled.—
onChange(value: string) => voidReports the new selected value.—
classNamestringClass of the root element.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.