ChoicesWidgetThis is a React component
SourceRender a list of choices.
The specific widget chosen is one of
- SelectAsyncChoicesWidget - when
asyncChoices
is provided.widgetType
is ignored in this case. - SelectChoicesWidget - when
widgetType="select"
orwidgetType
is not specified and there is more than 3 choices. - RadioChoicesWidget - when
widgetType="radio"
ormultiple={false}
andwidgetType
is not specified and there is 3 or fewer choices. - CheckboxChoicesWidget - when
widgetType="checkbox"
ormultiple={true}
andwidgetType
is not specified and there is 3 or fewer choices.
Parameter | Type | Description | |
---|---|---|---|
* | props | Any additional props are passed through to the specify widget | |
* | props.input | InputProps | The input props for the widget. This should include, at minimum:
Can also include
|
* | props.choices | Map|[(RawValue|RawValue[]), string][] | The choices to render. This can be a |
props.multiple | boolean | Whether multiple values are accepted | |
props.widgetType | "select"|"checkbox"|"radio" | Choices are rendered as either SelectChoicesWidget,
RadioChoicesWidget (only if |
Examples
Basic Usage
When the number of choices is small (<=3) the default is a radio widget, otherwise it
is a select widget. You can specify the type to use with widgetType
.
Any extra props are passed through to the underlying component (eg. showSearch
in the last example)
Multiple selection
Pass multiple
through to allow selection of multiple values. In this case the value will
be an array.
When the number of choices is small (<=3) the default is a checkbox widget, otherwise it
is a select widget. You can specify the type to use with widgetType
.
Any extra props are passed through to the underlying component (eg. showSearch
in the last example)