I'm trying to put together a R shiny app using bslib that includes a navset_card_pill tab feature.
I would like to include a title for the navset_card_pill that changes according to a reactive input. In the reprex below this input is a simple 3-option dropdown list ("option").
But I've found that although the reactive title will plot on the sidebar, it will not plot as the title for the navset_card_pill. A non-reactive title ("Test Title" in the reprex ) will plot as the navset_card_pill title though.
Is there a feature of navset_card_pill that prevents it from plotting reactive titles? Or, is there something I'm missing that is required for it to plot a reactive title?
Thanks in advance for any help.
################## REPREX
library(base)
library(glue)
library(shiny)
library(stringi)
library(bslib)
library(tidyverse)
optionList <- c("Option1","Option2","Option3")
ui <- page_sidebar(
This sidebar title plots
title=h1("Navset_Title_Test"),
theme = bs_theme( bootswatch="darkly"),
sidebar = sidebar(
position = "left",
title = h1(textOutput("optionType")),
selectInput("option","Select an Option",optionList,multiple=FALSE,width ='120px')
), # sidebar
navset_card_pill(
#. This title does not plot
title = h1(textOutput("optionType")),
#. Title below does plot when de-commented
title = h1("Test Title"),
nav_panel(h2("Tab1"),
br(),
p(stri_rand_lipsum(1, start_lipsum = TRUE)),
p(stri_rand_lipsum(1, start_lipsum = TRUE))
),
nav_panel(h2("Tab2"),
br(),
p(stri_rand_lipsum(1, start_lipsum = TRUE)),
p(stri_rand_lipsum(1, start_lipsum = TRUE))
),
nav_spacer()
) # navset_card_pill
) # page_sidebar
server <- function(input, output, session) {
output$optionType <- renderText({
paste(input$option)
})
} # server <- function(input, output, session)
Run the app
shinyApp(ui, server)
...