gabrieltempass / streamlit-navigation-bar

A component that allows you to place a navigation bar in your Streamlit app.
https://streamlit.io/
MIT License
136 stars 14 forks source link

st.switch_page() feature not supported by navbar #14

Open neldivad opened 5 months ago

neldivad commented 5 months ago

Checklist

Summary

Navbar does not allow transitioning with st.switch_page(). Will behave exactly like streamlit default multipage onwards.

Reproducible code example

# main.py
import streamlit as st
from streamlit_navigation_bar import st_navbar
import pages as pg

page = st_navbar(["Home", "Documentation", "Examples", "Community", "About"])

if page == 'Home':
    pg.homepage()
elif page == 'Documentation':
    pg.app1_page()
# pages/__init__.py

from .home import homepage
from .app1 import app1_page
from .app2 import app2_page
# pages/home.py
import streamlit as st

def homepage():
    st.title('Home')

    if st.button("Page 1"):
        st.switch_page('pages/app1.py')
# pages/app1.py
import streamlit as st

def app1_page():
    st.title('App 1')


### Steps to reproduce

_No response_

### Expected behavior

Takes me to a different page while keeping the navbar UI. 

### Current behavior

Takes me to streamlit default multipage UI. No other way to revert to navbar UI other than going back to the app's origin. 

### Is this a regression?

- [ ] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: 1.35
- Streamlit Navigation Bar version: 3.3.0
- Python version: 3.11
- Operating System: Windows
- Browser: Google chrome

### Additional information

_No response_