RadioChoicesWidget

Source
import { RadioChoicesWidget } from "@prestojs/ui-antd";
RadioChoicesWidget<ValueT>(props)

See Radio for props available

Params:
ParameterTypeDescription
*
props
An object with the properties below
props.asyncChoicesAsyncChoicesInterface

Any AsyncChoices, if applicable. This typically comes from Field.asyncChoices.

props.choicePropsMap

Any additional props to pass through to each choice. These are passed through to the radioComponent.

Should be a Map of the choice value to the props to pass through

*props.choicesMap|[ValueT, string][]

The choices to render. This can be a Map of value to label or an array of 2-element arrays [value, label].

*props.inputInputProps

The input props for the widget. This should include, at minimum:

  • onChange
  • value

Can also include

  • name
  • onBlur
  • onFocus
  • type
  • checked
  • multiple
props.metaRecord

Any extra details such as field errors, touched status etc. The values here depend on the form library in use. If using @prestojs/final-form see FieldRenderProps for what this will be.

props.radioComponentReact.ComponentType

The component to use for each choice (ie. the radio button). Defaults to Radio.

...any
Any properties from RadioGroupProps
Returns:React.ReactElement

Examples

Basic Usage

Any extra props are passed through to Radio.Group.

Choices are rendered as:

<Radio.Group>
    <Radio key="1" value="1">One</Radio>
    <Radio key="2" value="2">Two</Radio>
</Radio.Group>

You can customise the component used instead of Radio by passing radioComponent (eg. radioComponent={RadioChoicesWidget.Button}).

You can pass any extra props to each Radio by passing choiceProps which is a Map of choice value to the props to apply.