So I decided to create my own custom navigation bar with CSS. But needed a custom navigation component (navigation tabs). Took a while, but I finally got there. More work needs to be done but its my first time using typescript so please bare with me.
Firstly, you’d need to download the style.css file into your directory and load it as in the example in the github page above (see readme). Then import the component and you are good to go. I recently updated streamlit and noticed a change in the css, just one, that was related to the navigation bar (the stHeader) but have added this to the style css file. This is the main problem, as streamlit updates, changes to the navigation bar are to be expected but they can be easily adjusted with CSS.
Anyway, thanks streamlit, and enjoy everyone!
UPDATE
I have now implemented custom CSS to adjust tabs for your own custom navigation. I borrowed the CSS implementation from the wonderful Victoryhb’s option menu.
So… make your own nav bar using the CSS file (style) and build your own tabs to accommodate it.
This feature doesn’t work for me… I used an image background in my app, it might be the reason.
The navtab works well but the rest of the app does not move with it, and leave a blank column which is not good.
Hey, so sorry for the late response. I have looked into it and its an issue with streamlit’s sidebar css. It has a set min-width and a width of 335px I think. Removing those should make the package function as normal. Though I am having a bit of trouble making these changes in a css file. Will get back to you when I have figured this out.
section[data-testid='stSidebar']{
background-color: #111;
min-width:unset !important;
max-width: unset !important; /*<--- This part is optional.*/
width: unset !important;
flex-shrink: unset !important; /*<--- This part is optional.*/
}
`
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.