Search Bar
selectors.Search
Creates a input to perform search queries or introduce some text value.
| Parameter | Description | Default Value |
|---|---|---|
| selector_name | The name of the selector. It must be unique. | - |
| label | The label for the selector. If not passed, the selector shows its selector_name. | - |
| default_value | If selected option is invalid or not defined, use this value. | - |
| ignore_user_input | If passed True, picks default_value instead of the selected value. | False |
| allowed_values | List of valid values. If passed, this input will ignore other input values and use the default | - |
| placeholder | Short hint displayed in the input field before the user enters a value. | - |
| help_text | Tooltip help message displayed while the input is focused. | - |
| width | Custom selector width (numeric field). | - |
| run_on_change | If False is passed, changes in this selector will not trigger execution. | True |
| allow_clear | If True, allow remove input content with clear icon. | False |
| show_button | If True, the input will include a button to confirm selection. | False |
| show_icon | If True and showButton is True, the button will show a search icon. | True |
| button_text | If passed and showButton is True, this will set the button text. | - |
| button_color | If passed and showButton is True, this will set the button text color. | - |
| button_background | If passed and showButton is True, this will set the button background color. | - |
| block_uuid | Optional 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.