I wanted to ask if there is a functionality that lets you block some tabs till a condition happens.
Imagine my Streamlit App works as a “flow app”, that needs the code in the first tab already ran to make the second tab code work, so it doesn’t give errors.
I wanted to know if there is any way to “block” some tabs till a condition happens in the previous tab (like clicking a button, for example), so my app doesn’t break.
I would need this so the user of the app (not me, I already know that I shouldn’t click next tab if the current tab code is not done running) cannot break it while clicking other tabs.
You can have a session variables (either a common list for all the steps /tabs you have OR individual variables for each step /tab), each equating to True / False, to indicate that a step is complete or not. That way the user will need to complete the previous step before going on to the next step.
Thank you @Shawn_Pereira !
I assume that executing your response would make the second tab not work after clicking it, but I would like to find a way to “ban” the user of clicking this second tab, in order to not change tabs till this session state variable == True.
Is it possible to achieve this?
Hi @Monica_de_Santos_Rod, with the StepperBar component, you will be able to force the user to choose the 2nd option only after the 1st option is completed… You will need to pip install this component first (from the location mentioned above).
If you still want to use st.tabs, you can’t prevent / ban a user from clicking on a tab, but you can prevent showing or show details in the 2nd tab, based on if a result is achieved in the 1st tab.
Thank you @arnaud and @Shawn_Pereira for your answers and the demo!
I wanted to ask also for the same thing but for multipage apps, so instead of tabs if would be the different pages. Is this possible?
Thank you ! @Shawn_Pereira
I’m already using Streamlit Multipage-app.
Could you tell me the exact name of the functionality to block the pages with Hydralit or the Option-Menu Component? (I’ve been looking at the documentation but couldn’t find it)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.