Skip to content

Search input

An input with a magnifying glass icon and "Search…" as placeholder. It accepts every other parameter of ui.input.

ui.search_input · Category: Forms · Full reference →

Search inputSearch input
  • At the top of a list, tree or table to filter it as you type.
  • Pair it with ui.fuzzy_filter to rank the best matches first.
import pyzed as pz
from pyzed import ui
class Finder(pz.App):
def __init__(self):
self.query = ""
self.files = ["main.py", "app.py", "theme.py"]
def view(self):
matches = ui.fuzzy_filter(self.query, self.files)
return pz.column([
ui.search_input(self.query, lambda q: setattr(self, "query", q)),
*[ui.list_item(name, icon="file") for name, _ in matches],
], spacing=6)
Search input: EmptySearch input: Empty
Empty
Code
ui.search_input("", on_query, width=260)
Search input: With a querySearch input: With a query
With a query
Code
ui.search_input("button", on_query, width=260)
Search input: placeholder=Search input: placeholder=
placeholder=
Code
ui.search_input("", on_query, placeholder="Search components…", width=260)
Search input: size="sm"Search input: size="sm"
size="sm"
Code
ui.search_input("", on_query, size="sm", width=260)
Search input: size="lg"Search input: size="lg"
size="lg"
Code
ui.search_input("", on_query, size="lg", width=260)
Search input: borderless=TrueSearch input: borderless=True
borderless=True
Code
ui.search_input("", on_query, borderless=True, width=260)

Search input has 1 event of its own, listed below. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

Event Handler gets When
on_input (text) Callable that receives the new text on every keystroke.

Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().

The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.

class Finder(pz.App):
def __init__(self):
self.query = ""
self.files = ["main.py", "app.py", "theme.py"]
def search(self, text): # on_input: every keystroke
self.query = text
def view(self):
matches = ui.fuzzy_filter(self.query, self.files)
return pz.column([ui.search_input(self.query, self.search),
*[ui.list_item(name, icon="file") for name, _ in matches]], spacing=6)
search_input(value, on_input=None, *, placeholder='Search…', **kwargs)

An input with a magnifying glass icon.

Property Default Description
value required Current text.
placeholder "Search…" Hint text shown when empty.
**kwargs — Same as input.

Events: on_input (events).

Full reference →