๐Ÿ”Ž Streamlit Search

Example multi-page streamlit app that allows you to search through all the pages to find the one you want.

Hereโ€™s what it looks like:

Hereโ€™s the core code (from the ๐Ÿ”Ž Search.py file):

import os
import streamlit as st

st.set_page_config(
    page_title="Streamlit Search",
    page_icon="๐Ÿ”"
)

st.title("Streamlit Search")

clean_page = None

pages = sorted(os.listdir('pages'))
page2cleanpage = {
    page: ' '.join(page.split('_')[1:]).replace('.py', '')
    for page in pages
}
cleanpage2page = {
    cleanpage: page for page, cleanpage in page2cleanpage.items()
}

clean_pages = [page2cleanpage[page] for page in pages]
clean_page = st.selectbox(
    '๐Ÿ”Ž Search for a Dashboard',
    options=clean_pages,
    index=None,
    placeholder='start typing...',
)
if clean_page is not None:
    st.switch_page(
        f'pages/{cleanpage2page[clean_page]}'
    )
2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.