In my Shiny app I try to create tabsets completely dynamically. Using insertTab works when I have statically created a first tab, but how do I insert a tab into an empty tabset? Should I create the tabset only when the first tab name/icon is known?
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("add", "Add 'Dynamic' tab"),
),
mainPanel(
tabsetPanel(id = "tabs",
## Missing argument
# tabPanel("Hello", "This is the hello tab")
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$add, {
insertTab(inputId = "tabs",
tabPanel("Dynamic", "This a dynamically-added tab"),
target = ""
)
})
}
shinyApp(ui, server)