import panel as pn
pn.extension()
The AutocompleteInput
widget allows selecting a value
from a list or dictionary of options
by entering the value into an auto-completing text field. It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup
, Select
and DiscreteSlider
widgets.
For more information about listening to widget events and laying out widgets refer to the widgets user guide. Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the param user guide. To express interactivity entirely using Javascript without the need for a Python server take a look at the links user guide.
For layout and styling related parameters see the customization user guide.
options
(list): A list of options to select fromrestrict
(boolean): Set to False in order to allow users to enter text that is not present in the options list.value
(str): The current value updated when pressing value_input
(str): The current value updated on every key press.case_sensitive
(boolean): Enable or disable case sensitivity for matching completions.disabled
(boolean): Whether the widget is editablename
(str): The title of the widgetplaceholder
(str): A placeholder string displayed when no option is selectedmin_characters
(int): The number of characters a user must type before completions are presented.autocomplete = pn.widgets.AutocompleteInput(
name='Autocomplete Input', options=['Biology', 'Chemistry', 'Physics'],
placeholder='Write something here')
pn.Row(autocomplete, height=100)
Like most other widgets, AutocompleteInput
has a value parameter that can be accessed or set:
autocomplete.value
If restrict=False
the AutocompleteInput
will allow any input in addition to the completions it offers:
not_restricted = autocomplete.clone(value='Mathematics', restrict=False)
pn.Row(not_restricted, height=100)
not_restricted.value
The AutocompleteInput
widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:
pn.Row(autocomplete.controls(jslink=True), autocomplete)