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 →


pz.column([ ui.search_input("", on_query), ui.search_input("button", on_query, placeholder="Search components…"),], spacing=10, width=360)When to use
Section titled “When to use”- At the top of a list, tree or table to filter it as you type.
- Pair it with
ui.fuzzy_filterto rank the best matches first.
import pyzed as pzfrom 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)Variants
Section titled “Variants”Content
Section titled “Content”

Code
ui.search_input("", on_query, width=260)

Code
ui.search_input("button", on_query, width=260)

placeholder=Code
ui.search_input("", on_query, placeholder="Search components…", width=260)

size="sm"Code
ui.search_input("", on_query, size="sm", width=260)

size="lg"Code
ui.search_input("", on_query, size="lg", width=260)

borderless=TrueCode
ui.search_input("", on_query, borderless=True, width=260)Events
Section titled “Events”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().
Handling the events
Section titled “Handling the events”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)from dataclasses import dataclass
@dataclassclass Search: query: str
class Finder(pz.App): query = "" files = ["main.py", "app.py", "theme.py"]
def update(self, message): match message: case Search(query): self.query = query
def view(self): matches = ui.fuzzy_filter(self.query, self.files) return pz.column([ui.search_input(self.query, Search), *[ui.list_item(name, icon="file") for name, _ in matches]], spacing=6)from dataclasses import dataclass
@dataclass(frozen=True)class State: query: str = "" files: tuple = ("main.py", "app.py", "theme.py")
def view(state, set_state): matches = ui.fuzzy_filter(state.query, list(state.files)) return pz.column([ui.search_input(state.query, lambda q: set_state(query=q)), *[ui.list_item(name, icon="file") for name, _ in matches]], spacing=6)Properties and API
Section titled “Properties and API”ui.search_input
Section titled “ui.search_input”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).