Dynamically show or hide a tab_panel
or navbar_menu
show_tab(session = shiny::getDefaultReactiveDomain(), id, target)
hide_tab(session = shiny::getDefaultReactiveDomain(), id, target)
The session
object passed to function given to shinyServer
.
The id of the navbar object
The tab value to toggle visibility
Changes to the visibility of a tab in the shiny UI.
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)
}