ListInput
Repeatable list of input components that can be dynamically added or removed.
Examples
Basic Usage
This example runs a form with a single page containing the widget
Example Code
from abstra.forms import ListInput, NumberInput, TextInput, run
item_template = [
TextInput("Item Name", key="item_name"),
NumberInput("Item Quantity", key="item_quantity"),
]
# Create a page with the widget
example_page = [ListInput(key="my-list", template=item_template, min=2)]
# Run the form
result = run([example_page])
# Print the result
print(result)
Parameters
Name | Description | Type | Default |
---|---|---|---|
key (required) | Identifier for the widget. | str | None |
template (required) | Template or function that returns a template for each list item. | Union[Template, TemplateFunction] | None |
min | Minimum number of items required. | int | 0 |
max | Maximum number of items allowed. | int | None |
hint | Help text displayed below the input. | str | None |
add_button_text | Text displayed on the button to add a new item. | str | '+' |
full_width | Whether the input should take up the full width of its container. | bool | False |
required | Whether at least one item is required. | bool | True |
disabled | Whether the input is non-interactive. | bool | False |
errors | Pre-defined validation error messages to display. | Union[List[str], str] | None |
State Value
List[State]
: The list of states for each item in the list. State is a dictionary-like object that holds the values for each input in the list indexed by their keys.
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