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

dynamically set nav_bar title #1700

Open
micboat opened this issue Sep 23, 2024 · 2 comments
Open

dynamically set nav_bar title #1700

micboat opened this issue Sep 23, 2024 · 2 comments

Comments

@micboat
Copy link

micboat commented Sep 23, 2024

Instead of using "Current Year" and "Base Year" as the title of my nav_bar, how can I set those to dynamically respond to the year selected.

from shiny.express import render, input, ui, output_args, session

with ui.sidebar(open="open"):
    ui.input_selectize(
        "currentyear_filter",  ui.h6("Select Comparison Years"), 
        choices=['2023', '2024'],
        selected="2024",
        multiple=False
    )

    ui.input_selectize(
        "baseyear_filter", 
        "",
        choices=['2016', '2023', '2024'], 
        selected="2023",
        multiple=False
    )
    
    

with ui.nav_panel("Data"): 
            with ui.navset_card_tab(id='tables'):
                with ui.nav_panel( "Current Year"):  #TODO: set current year nav title based 'currentyear_filter'
                    print("Current Year Content Here")
                    
                with ui.nav_panel( "Base Year"):  #TODO: set base year nav title based 'baseyear_filter'
                    print("Base Year Content Here")
@ramnathv
Copy link

ramnathv commented Sep 24, 2024

One solution would be to use render.express.

Shinylive URL

@render.express
def ui_navset_dynamic():
    with ui.navset_card_tab(id='tables'):
        with ui.nav_panel(input.currentyear_filter()):
            "Current Year Content Here"
        with ui.nav_panel(input.baseyear_filter()):
            "Base Year Content here"

@micboat
Copy link
Author

micboat commented Sep 24, 2024

Excellent, that worked, thanks @ramnathv !

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

No branches or pull requests

2 participants