Description Usage Arguments Details See Also Examples
Dynamically hide or show a tabPanel() (or a
navbarMenu())from an existing tabsetPanel(),
navlistPanel() or navbarPage().
1 2 3 | showTab(inputId, target, select = FALSE, session = getDefaultReactiveDomain())
hideTab(inputId, target, session = getDefaultReactiveDomain())
|
inputId |
The |
target |
The |
select |
Should |
session |
The shiny session within which to call this function. |
For navbarPage, you can hide/show conventional
tabPanels (whether at the top level or nested inside a
navbarMenu), as well as an entire navbarMenu().
For the latter case, target should be the menuName that
you gave your navbarMenu when you first created it (by default,
this is equal to the value of the title argument).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ## Only run this example in interactive R sessions
if (interactive()) {
ui <- navbarPage("Navbar page", id = "tabs",
tabPanel("Home",
actionButton("hideTab", "Hide 'Foo' tab"),
actionButton("showTab", "Show 'Foo' tab"),
actionButton("hideMenu", "Hide 'More' navbarMenu"),
actionButton("showMenu", "Show 'More' navbarMenu")
),
tabPanel("Foo", "This is the foo tab"),
tabPanel("Bar", "This is the bar tab"),
navbarMenu("More",
tabPanel("Table", "Table page"),
tabPanel("About", "About page"),
"------",
"Even more!",
tabPanel("Email", "Email page")
)
)
server <- function(input, output, session) {
observeEvent(input$hideTab, {
hideTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$showTab, {
showTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$hideMenu, {
hideTab(inputId = "tabs", target = "More")
})
observeEvent(input$showMenu, {
showTab(inputId = "tabs", target = "More")
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.