Skip to main content

Search Bar

selectors.Search

Creates a input to perform search queries or introduce some text value.

ParameterDescriptionDefault Value
selector_nameThe name of the selector. It must be unique.-
labelThe label for the selector. If not passed, the selector shows its selector_name.-
default_valueIf selected option is invalid or not defined, use this value.-
ignore_user_inputIf passed True, picks default_value instead of the selected value.False
allowed_valuesList of valid values. If passed, this input will ignore other input values and use the default-
placeholderShort hint displayed in the input field before the user enters a value.-
help_textTooltip help message displayed while the input is focused.-
widthCustom selector width (numeric field).-
run_on_changeIf False is passed, changes in this selector will not trigger execution.True
allow_clearIf True, allow remove input content with clear icon.False
show_buttonIf True, the input will include a button to confirm selection.False
show_iconIf True and showButton is True, the button will show a search icon.True
button_textIf passed and showButton is True, this will set the button text.-
button_colorIf passed and showButton is True, this will set the button text color.-
button_backgroundIf passed and showButton is True, this will set the button background color.-
block_uuidOptional value to specify the block that will be executed when the selector triggers execution.(current block uuid)

Example

sel = selectors.Search(
'searchbar-0',
label='Your label',
placeholder='Please write something',
help_text='Enter a word or a sentence',
)
sel.render()
print("You have selected", sel.value)
from IPython.display import display, HTML
elements =[]
searchbar = selectors.Search(
'searchbar-1',
label='',
placeholder='My search bar placeholder',
help_text='Enter a word or a paragraph',
)
elements.append(searchbar)

searchbar = selectors.Search(
'searchbar-2',
label='Search Label',
placeholder='my search bar placeholder',
help_text='Enter a word or a paragraph',
default_value='ipsum',

)
elements.append(searchbar)

searchbar = selectors.Search(
'searchbar-3',
label='Search Label',
placeholder='my search bar placeholder',
help_text='Enter a word or a paragraph',
default_value='ipsum',
show_button=True,
)
elements.append(searchbar)

searchbar = selectors.Search(
'searchbar-4',
label='Search Label',
placeholder='my search bar placeholder',
help_text='Enter a word or a paragraph',
default_value='ipsum',
allowed_values=['i', 'et', 'dolor'],
allow_clear=True,

)
elements.append(searchbar)

searchbar = selectors.Search(
'searchbar-5',
label="",
placeholder='my search bar placeholder',
help_text='Enter a word or a paragraph',
default_value='ipsum',
allow_clear=True,
show_button=True,
button_text='Search'
)
elements.append(searchbar)

searchbar = selectors.Search(
'searchbar-6',
label="",
placeholder='my search bar placeholder',
default_value='ipsum',
allow_clear=True,
show_button=True,
show_icon=False,
button_color='darkgreen',
button_background='#bbffff',
button_text='Go!',
width=600
)
elements.append(searchbar)

elements_html = "".join(
f'<tr><td>{element}</td><td>{element.value}</td></tr>'
for element in elements
)

display(HTML(f"""
<table>
{elements_html}
</table>
"""))

See also

  • Textarea — a related free-text input for longer values.
  • All selector types — the full catalog of available selector controls.
  • Selectors — common arguments and how to define, render, and read selectors.