Now I would like to style my multipage app and put a logo with a title on top of/before the page navigation in the sidebar. To stick with the documentation, I want to include the logo before “Home, …”:
Ohhh, I see, sorry I read too quickly and misunderstood your question. I thought you meant on the main canvas, not on the sidebar! :c
Yes, the “pages menu” will be on the top of the sidebar. Don’t think you can get around that (at least on a safe way. Maybe there’s a css trick to do it?)
One option is to use CSS, as @sebastiandres suggested. It’s a big hacky, but if you make this function, and call it on each page, it will give you this behavior. Note that depending on the size of your logo, you would want to change various numbers on this, but it should point you in the right direction.
I can’t seem to get this to work with a local file.
I tried replacing background-image: url(http://placekitten.com/200/200); with the name of my local file (in my app’s main page directory) as well as the relative path but it didn’t work for me.
Also searched for “css background-image local file” and used the format ../..I found here, but did not work as well.
the answer on Stackoverflow was my adaption in order to serve local files which streamlit does not per default. Let me know if you find a better solution.
From my point of view, the cleanest solution would be to make the “multipage menu” a regular streamlit component in order to place it in the sidebar or canvas like other components.
For instance, it could be used like:
my_menu = st.multipage_menu(my_caption)
or
st.sidebar.multipage_menu(my_caption)
or
col1.multipage_menu(my_caption)
and would only be rendered/available if a pages directory exists and holds valid pages.
I can imagine why the developers have implemented it as the first element in the sidebar due to page configuration, etc.
But maybe this could be changed in future versions as I am guessing many people would like to add logos on top of it or place it somewhere else!?
Hello Streamlit community
I am looking for the same problem, I want to push mu logo and title at the top in streamlit application. I tried CSS solution, but it won’t work for me maybe I am mistaking it. Could you please help to solve this?
@Priti_Asolkar If you’re interested, there is a component for this as part of streamlit-extras https://extras.streamlit.app/App%20logo. There will be a release shortly that will support local image files, but it should work already with urls.
I have been using the solution provided by @blackary and it’s been working well, but I’ve noticed that if I have something on the sidebar, like an input widget, and the screen is small enough, when scrolling through the menu, the links will be covered by the logo. Is it possible to get the logo to scroll with the rest of the menu if the need to scroll is present? Alternately, could text that goes “below” the image be hidden?
Hi,
Do we have any news on this?
I have been using @blackary solution, but I noticed that if I add this piece of code on top of every page It is very jumpy when moving from page to page and that kinda bothers me.
I add the @st.cache_data right before the definition of the add_logo() function but still no luck. It is very jumpy, is annoying.
Thanks a lot! But where do I have to place the file with that function? I have added a logo.py file with that function inside the main folder, but this is not working.
You need to call add_logo() on every page. Whether you do that by calling add_logo() directly, or calling a function that calls add_logo(), it doesn’t matter.
Yes, I understand. But where do I have to add the file with that kind of global function? Inside the page folder? Sorry for my stupid question, but I am still learning Python.
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.