% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glass_tabs.R
\name{appendGlassTab}
\alias{appendGlassTab}
\alias{removeGlassTab}
\title{Append or remove a glass tab at runtime}
\usage{
appendGlassTab(session, id, tab, select = FALSE)

removeGlassTab(session, id, value)
}
\arguments{
\item{session}{Shiny session object.}

\item{id}{Module id matching the \code{id} passed to \code{\link[=glassTabsUI]{glassTabsUI()}}.}

\item{tab}{A \code{\link[=glassTabPanel]{glassTabPanel()}} object (for \code{appendGlassTab()} only).}

\item{select}{Logical. If \code{TRUE}, the new tab is immediately activated.
Defaults to \code{FALSE}.}

\item{value}{Value of the tab to remove (for \code{removeGlassTab()} only).}
}
\value{
Called for its side effect; returns \code{NULL} invisibly.
}
\description{
\code{appendGlassTab()} adds a new \code{\link[=glassTabPanel]{glassTabPanel()}} to an existing
\code{\link[=glassTabsUI]{glassTabsUI()}} at runtime. \code{removeGlassTab()} removes a tab by value.
If the removed tab was active, the first remaining tab is activated.
}
\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)
}
}
