A Streamlit component is an encapsulated interface element declared and parameterized in Python, while Streamlit renders the required web-page pieces. This avoids writing individual HTML fragments and JavaScript for client-side interactivity. section 9.1.3
Player search workflow
Install streamlit-searchbox, import st_searchbox, and place two parameterized search boxes in columns. Each box calls search_players when its value changes, supports autocomplete, and returns the selected player. The selections can drive a database query and display match history in a DataFrame. 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"
)
Shows two searchbox components configured with Python callbacks, labels, keys, defaults, placeholders, and column layout. section 9.1.3
