Pre st.navigation we were using streamlit-pages which has hide_pages().
Afaik for a route to exist one must add the page to st.navigation but there no simple way to control which pages render in the nav.
Pre st.navigation we were using streamlit-pages which has hide_pages().
Afaik for a route to exist one must add the page to st.navigation but there no simple way to control which pages render in the nav.
I’ve had to set navigation to hidden and then build a custom nav to handle hiding pages while being routable. At least now the sidebar seems a little more flexible and page_link exits.
However, it’s disappointing that a new component like navigation is still being built in ways that isn’t flexible. coupling routing and navigation rendering is a bad design decision IMHO. I get it makes it a little more batteries included. But if this was built in a more composable fashion you should have been able to achieve the best of both worlds. And it would have saved me a bunch coding that adds zero value our app.
please please please stop wrapping several things into magic boxes that do a thing just “one” way.
Hey @janaka, thanks for your feedback.
st.navigation was built with the strengths of st_pages in mind. So much that you can see st_pages now relying on st.navigation in the latest release by @blackary - hopefully you don’t experience any regression moving from one to the other.
I do think the new API has come to a rather composable state, since you can now:
st.Page
from a file or callablest.Page.run()
switch_page
page_link
It seems like you’ve been missing documentation to help you “get off the magic track” to build your custom navigation, in particular through the client.showSidebarNavigation config parameter. Is that right? Did you happen to land on that related page Create a dynamic navigation menu - Streamlit Docs?
Or is there any missing feature?
I think I did come across the dynamic nav docs but mainly used the ones here Define multipage apps with st.Page and st.navigation - Streamlit Docs. The docs were sufficient once I’d figured I had to build custom nav.
we don’t use a config.toml. any server config is passed in a cli params. anything else is don’t programmatically. especially don’t want to control any app UI behaviour via a config file. anything we want to configure like server related, we only want to use env vars, that’s the one way.
used position=hidden to turn off the default nav. that needs all kinds of wrong as an API tbh. Back to my point about composition. I agree that Page and page_link are composable. But what’s going on with navigation
?! that’s got at least two responsibilities: routing and nav UI render. those should be available separately IMHO.
That shouldn’t be a blocker, you may pass any of the params in config.toml
as a CLI param, right
# config.toml
[client]
showSidebarNavigation=false
is equivalent to
$ streamlit run streamlit_app.py --client.showSidebarNavigation false
Wanna provide an API sketch of what you would have preferred?
yep, but don’t want to configure UI behaviour this way. We do precisely this for server stuff which. UI any UI related config we want to control programmatically. So as long as everything client related can be set programmatically all is good.
yeah, I’ll share something over the next few days.
appreciate you engaging on this
Hi, sorry, didn’t get back to you, been slammed, still am.
Here a rough incomplete sketch to illustrate the idea of separation. In a nutshell it’s the established model in web frameworks.
page
- all config related to a page. separate props for display title on page, browser title, browser description, URL slug, etc. don’t re-use a prop for unrelated cases (default sure but enable setting for granular control).
st.router.add(page.get_route())
- handle all the routing setup, adding page route to Tornado etc.
st.nav.add(page)
or st.nav(page[])
st.nav
internally sets routes e.g. calls router.add()
for each page.
st.nav.hide_pages(page) - hides page in nav. doesn’t make sense to have a prop on page
for this because page
A user should be able to build a custom nav with access to all the same building blocks as st.nav
.
Hope that helps and makes sense.
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.
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.
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.
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.