DropdownInput
Dropdown select widget allowing selection from predefined options.
Examples
Basic Usage
This example runs a form with a single page containing the widget
Example Code
from abstra.forms import DropdownInput, run
# Create a page with the widget
example_page = [
DropdownInput(
label="Dropdown Input",
key="my-dropdown_input",
options=["Option A", "Option B", "Option C"],
),
]
# Run the form
result = run([example_page])
# Print the result
print(result)
Parameters
Name | Description | Type | Default |
---|---|---|---|
label (required) | Text label displayed above the dropdown. | str | None |
options (required) | List of options to choose from, either as {"label": str, "value": str} dictionaries or simple strings. | Union[List[LabelValueDict], List[str]] | None |
key | Identifier for the widget, defaults to label if not provided. | str | None |
required | Whether a selection is required before proceeding. | bool | True |
hint | Help text displayed below the dropdown. | str | None |
placeholder | Text shown when no option is selected. | str | '' |
full_width | Whether the dropdown should take up the full width of its container. | bool | False |
disabled | Whether the dropdown is non-interactive. | bool | False |
multiple | Whether multiple options can be selected. | bool | False |
min | Minimum number of selections required when multiple=True. | int | None |
max | Maximum number of selections allowed when multiple=True. | int | None |
errors | Pre-defined validation error messages to display. | Union[List[str], str] | None |
State Value
Union[List[object], object, None]
: The selected value(s) from the dropdown options. 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