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.