Good stuff!
I’m very excited if at some point we can freely choose between using the st.sidebar(left or right) or a navbar like this when you need something a little more website-like.
But this is a super nice example of how it could work together
If you press on the button, will it kill the current process? because that’s why i’ve used a wrapper, when paginating with an IFRAME, the process get’s killed AFAIK, so if a heavy process is runnig, the navigation will take time.
As per my understanding of your question,
if you are on page1, upon clicking page2 it will forget page1(You have to use session state)
pls, ask me if I misunderstood your question.
When using the navbar ive “created” when you swtich between the views, the previous one gets just down immidiatly, due the fact that its a ridirect, and as far as i understood, the proccess also gets killed, so the navigation is really fast.
When i trying to make something with tabs from inside streamlit, the application took time to first finish her run (for example if if had like 10 sec proccess going, the app would first need to finish running it, and only after that, the redirection would accure).
Stand alone Navbar custom component that can be used directly for what it’s worth, Hydralit Components, as simple as;
import streamlit as st
import hydralit_components as hc
# specify the primary menu definition
menu_data = [
{'icon': "far fa-copy", 'label':"Left End"},
{'id':'Copy','icon':"🐙",'label':"Copy"},
{'icon': "far fa-chart-bar", 'label':"Chart"},#no tooltip message
{'icon': "far fa-address-book", 'label':"Book"},
{'id':' Crazy return value 💀','icon': "💀", 'label':"Calendar"},
{'icon': "far fa-clone", 'label':"Component"},
{'icon': "fas fa-tachometer-alt", 'label':"Dashboard",'ttip':"I'm the Dashboard tooltip!"}, #can add a tooltip message
{'icon': "far fa-copy", 'label':"Right End"},
]
# we can override any part of the primary colors of the menu
#over_theme = {'txc_inactive': '#FFFFFF','menu_background':'red','txc_active':'yellow','option_active':'blue'}
over_theme = {'txc_inactive': '#FFFFFF'}
menu_id = hc.nav_bar(menu_definition=menu_data,home_name='Home',override_theme=over_theme)
#get the id of the menu item clicked
st.info(f"{menu_id=}")
Features include
Full theme color support with complete override
Full container support (can put on sidebar too)
Responsive layout
Use Bootstrap icons or emojis or nothing
Configure Response values when clicked
Assign tooltips
Or you can use a full-blooded Streamlit multi-app framework package Hydralit, but everyone’s got a multi-app package and navbar now, so whatever you’re more comfortable with, still love your work @BugzTheBunny !
Glad you’re enjoying it, thanks! Funny you should ask, as I’m currently working on the next release of Hydralit and the Hydralit Components (including Navbar) and a new feature will be exactly what you are asking. Here is a video demonstrating how the navbar will become stuck to the top, even when scrolling. At the ~15 second mark, i toggle the parameter in the Hydralit constructor that will make the navbar stick to the top and you can see it snap to the top and stay there, so yes, it’s possible and coming soon!
This looks so freaking good as a navbar(loving the icon choice as well) without having to resort to the sidebar.
Could you share a video or gif how it looks like when resized to a mobile screen? Curious if all the nav items will work well this way
This comment might help the dev team as well to maximize performance when switching views/tabs for the official navbar.
For me ideally a combination of the performance of the navbar @BugzTheBunny made and the look of @Probability would be the perfect navbar.
Enabling theming on a performant navbar would solve it all since we would then have a fast navbar and let people themselves decide if they want a clean and simple look or one with icons/different colors/animations.
Hi @Fhireman, @mkleinbort@Manal_Benchrif , As previously mentioned, I’ve been working on a new release, why wait for the dream level stuff! The new features appear to be what everyone was waiting for, sticky nav, animated dropdown menus and full responsive collapse using the burger, a few more things but these are the main ones.
@BugzTheBunny, thanks for the inspiration, wanting to recreate your navbar while staying in Streamlit was the primary motivation for this update, that and I hated not having animated dropdown menus!
All locked and loaded, just pip the update and you’re good to go, pip install -U hydralit_components
Thank you so much for your hard work, this release is really amazing.
I test it and it work very well . I’m use it in my current project and it’s really helpful.
Please i have a suggestion if you can make it true. Each time we click in a new item in menu , the navbar goes down then up, it will be more ideal and perform if the navigation bar remains fixed.
Also please can you make a documentation how to create the sub items i really need it in my project as soon as possible.
Thanks, glad it works, was a fair bit of work to get Streamlit to play nice. To answer your questions;
I can’t change that movement behaviour, as it’s Streamlit itself that is injecting a page divider upon every refresh action, sorry, there are limits to what i can get Streamlit to stop showning.
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.