appendGlassTab() adds a new glassTabPanel() to an existing
glassTabsUI() at runtime. removeGlassTab() removes a tab by value.
If the removed tab was active, the first remaining tab is activated.
Arguments
- session
Shiny session object.
- id
Module id matching the
idpassed toglassTabsUI().- tab
A
glassTabPanel()object (forappendGlassTab()only).- select
Logical. If
TRUE, the new tab is immediately activated. Defaults toFALSE.- value
Value of the tab to remove (for
removeGlassTab()only).
Examples
if (interactive()) {
library(shiny)
ui <- fluidPage(
useGlassTabs(),
glassTabsUI(
"tabs",
glassTabPanel("home", "Home", p("Home content"), selected = TRUE)
),
actionButton("add", "Add tab"),
actionButton("remove", "Remove tab")
)
server <- function(input, output, session) {
observeEvent(input$add, {
appendGlassTab(session, "tabs",
glassTabPanel("new", "New Tab", p("Dynamic content")),
select = TRUE
)
})
observeEvent(input$remove, {
removeGlassTab(session, "tabs", "new")
})
}
shinyApp(ui, server)
}