How to programmatically select an arbitrary named tab in a bs4TabSetPanel?

Hi,

How would you change the (working) code below so that the tab names are different (say "tab one" and "tab two" instead). I haven't found a way to use arbitrary names.

if (interactive()) {
  library(shiny)
  library(bs4Dash)
  
  shinyApp(
    
    ui = bs4DashPage(
      
      sidebar_collapsed = FALSE,
      
      body = bs4DashBody(
        
        bs4TabSetPanel(
          id = "tabset",
          side = "left",
          
          bs4TabPanel(
            tabName = "Tab 1",
            active = TRUE
          ),
          bs4TabPanel(
            tabName = "Tab 2",
            active = FALSE
          )
        )
      ), # body
      
      sidebar = bs4DashSidebar(
        actionButton(inputId = "btn", label = "Select tab 2")
      ),
      controlbar = bs4DashControlbar(skin = "light")
    ), # page
    
    server = function(input, output, session) {
      
      observeEvent(input$btn, {
        updatebs4TabSetPanel(
          session,
          inputId = "tabset",
          selected = 2
        )
      })
    }
  )
}

Thanks for your help,

Julien

DGranjon

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.