Dynamically show or hide a tab_panel or navbar_menu

show_tab(session = shiny::getDefaultReactiveDomain(), id, target)

hide_tab(session = shiny::getDefaultReactiveDomain(), id, target)

Arguments

session

The session object passed to function given to shinyServer.

id

The id of the navbar object

target

The tab value to toggle visibility

Value

Changes to the visibility of a tab in the shiny UI.

Examples

if (interactive()) {
  library(shiny)
  library(shiny.semantic)

  ui <- navbar_page(
    title = "App Title",
    id = "navbar",
    tab_panel(
      "Plot",
      action_button("hide", "Hide Table"),
      action_button("show", "Show Table"),
      value = "plot"
    ),
    tab_panel("Summary", value = "summary"),
    tab_panel("Table", value = "table")
  )

  server <- function(input, output, session) {
    observeEvent(input$hide, hide_tab(session, "navbar", "table"))
    observeEvent(input$show, show_tab(session, "navbar", "table"))
  }

  shinyApp(ui, server)
}