Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Support for spinner? #86

Open
pvachon-ivadolabs opened this issue Jan 30, 2025 · 1 comment
Open

[Question] Support for spinner? #86

pvachon-ivadolabs opened this issue Jan 30, 2025 · 1 comment

Comments

@pvachon-ivadolabs
Copy link

Has anyone found a way to show a spinner when running the search function? For example, I make API calls that can sometimes take 3-4 seconds to return results and I would like to be able to show a spinner of some sort in the UI.

@m-wrzr
Copy link
Owner

m-wrzr commented Mar 3, 2025

Hey, you could add the spinner to the search function itself, maybe with a placeholder depending on where you'd like to indicate it running?

import time

import streamlit as st

from streamlit_searchbox import st_searchbox


def search(searchterm: str) -> list[str]:
    with placeholder:
        with st.spinner("Searching..."):
            time.sleep(5)
            return [f"{searchterm}-{i}" for i in range(10)]


placeholder = st.empty()

st.title("Searchbox test")


st_searchbox(search)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants