liveBook · Manning

St_searchbox

As explained in DuckDB in Action

st_searchbox is the Python function exposed by streamlit-searchbox for rendering and interacting with a search box component.

st_searchbox renders an interactive search box in a Streamlit app. Pass a search function as its first argument; the function runs when the user changes the query and supplies matching results. section 9.1.3

Choose two players

Place two search boxes in Streamlit columns, label them separately, and provide different defaults such as Roger Federer and Rafael Nadal. Selecting a result assigns the chosen player to the corresponding variable, which can then parameterize a database query. section 9.1.3

Listing 9.3 Parameterizing a Streamlit component with Python
left, right = st.columns(2)  #1
with left:
    player1 = st_searchbox(search_players,  #2
        label="Player 1",
        key="player1_search",
        default="Roger Federer",
        placeholder="Roger Federer"
    )
with right:
    player2 = st_searchbox(search_players,
        label="Player 2",
        key="player2_search",
        default="Rafael Nadal",
        placeholder="Rafael Nadal"
    )

The runnable pattern combines columns, a search_players callback, labels, keys, defaults, and placeholders. section 9.1.3

How DuckDB in Action covers it

How deep it goes
Explains installation, import, callback behavior, layout, defaults, and selection, but defers component implementation internals.
Examples
Demonstrates paired player searches for Roger Federer, Rafael Nadal, and Andy Murray.
What it assumes
Assumes basic Python and Streamlit app structure while showing installation and import from zero.
What you can do after
Apply it via streamlit-searchbox to build interactive search inputs whose selections feed downstream Python and database logic.
How it connects
Connects Streamlit components, autocomplete, Python callbacks, columns, database queries, and DataFrames.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.