Skip to contents

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.

Usage

appendGlassTab(session, id, tab, select = FALSE)

removeGlassTab(session, id, value)

Arguments

session

Shiny session object.

id

Module id matching the id passed to glassTabsUI().

tab

A glassTabPanel() object (for appendGlassTab() only).

select

Logical. If TRUE, the new tab is immediately activated. Defaults to FALSE.

value

Value of the tab to remove (for removeGlassTab() only).

Value

Called for its side effect; returns NULL invisibly.

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)
}