Skip to main content

MultipleChoiceInput

Multiple choice input widget for selecting a single option from a set of radio buttons.

Examples

Basic Usage

This example runs a form with a single page containing the widget

Example Code

from abstra.forms import MultipleChoiceInput, run

# Create a page with the widget
example_page = [
MultipleChoiceInput(
label="Multiple Choice Input",
key="my-multiple_choice_input",
options=["Option A", "Option B", "Option C"],
),
]

# Run the form
result = run([example_page])

# Print the result
print(result)

Parameters

NameDescriptionTypeDefault
label (required)Text label displayed above the options.strNone
options (required)List of options to choose from, either as {"label": str, "value": str} dictionaries or simple strings.Union[List[LabelValueDict], List[str]]None
keyIdentifier for the widget, defaults to label if not provided.strNone
requiredWhether an option must be selected before proceeding.boolTrue
hintHelp text displayed below the options.strNone
full_widthWhether the widget should take up the full width of its container.boolFalse
disabledWhether the widget is non-interactive.boolFalse
multipleWhether multiple options can be selected.boolFalse
minMinimum number of options that can be selected.intNone
maxMaximum number of options that can be selected.intNone
errorsPre-defined validation error messages to display.Union[List[str], str]None

State Value

Optional[Union[List[Any], Any, None]]: The selected option value. If multiple is True, this can be a list of values; otherwise, it is a single value or None.

info

This is the type of the value that this widget holds. It will show up when accessing widget's state item.

This also defines which value type can be used on initial_state