Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Express] page_auto() doesn't let you give page_navbar() an id #1036

Open
gadenbuie opened this issue Jan 19, 2024 · 1 comment
Open

[Express] page_auto() doesn't let you give page_navbar() an id #1036

gadenbuie opened this issue Jan 19, 2024 · 1 comment
Labels

Comments

@gadenbuie
Copy link
Collaborator

I wasn't able to find a user-friendly way of passing id from ui.page_opts() to page_navbar(). This is useful when server side logic needs to know which nav_panel() is currently active.

Here's the solution I came up with in Express:

from shiny import reactive
from shiny.express import input, ui
from shiny.ui import page_navbar

ui.page_opts(
    title="App with navbar",
    page_fn=lambda *args, **kwargs: page_navbar(*args, id="page", **kwargs),
)

with ui.nav_panel("A"):
    "Page A content"

with ui.nav_panel("B"):
    "Page B content"

with ui.nav_panel("C"):
    "Page C content"


@reactive.effect
def _():
    print(f"Page: {input.page()}")
@gadenbuie
Copy link
Collaborator Author

gadenbuie commented Jan 19, 2024

Similarly, shiny.ui.page_navbar() takes position and a few other useful options. Notably, both id and position are highlighted in https://shiny.posit.co/py/layouts/navbars.html and are hard to reach in Express.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant