Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bs4InsertTab

Insert a bs4TabPanel in a bs4TabSetPanel


Description

Usage

bs4InsertTab(
  inputId,
  tab,
  target,
  position = c("before", "after"),
  select = FALSE,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

bs4TabSetPanel id.

tab

bs4TabPanel to insert.

target

bs4TabPanel after of before which the new tab will be inserted.

position

Insert before or after: c("before", "after").

select

Whether to select the newly inserted tab. FALSE by default.

session

Shiny session object.

Examples

if (interactive()) {
 library(shiny)
 library(bs4Dash)
 
 ui <-  bs4DashPage(
   sidebar_collapsed = T,
   sidebar = bs4DashSidebar(),
   bs4DashFooter(),
   body = bs4DashBody(
     actionButton("add1","ADD tabset 1"),
     bs4TabSetPanel(
       id = "tabset1", 
       side = "left",
       bs4TabPanel(
         tabName = "Tab 1",
         active = TRUE,
         p("Text 1"),
       ),
       bs4TabPanel(
         tabName = "Tab 2",
         active = FALSE,
         p("Text 2"),
       )
     ),
     actionButton("add2","ADD tabset 2"),
     bs4TabSetPanel(
       id = "tabset2", 
       side = "left",
       bs4TabPanel(
         tabName = "Tab 1",
         active = TRUE,
         p("Text 1"),
       ),
       bs4TabPanel(
         tabName = "Tab 2",
         active = FALSE,
         p("Text 2"),
       )
     )
   )
 )
 
 server <- function(input, output, session) {
   
   observeEvent(input$add1, {
     bs4InsertTab(
       inputId = "tabset1",
       bs4TabPanel(tabName = "Dynamic", "I am inserted"),
       target = "Tab 1",
       position = "after",
       select = FALSE
     )
   })
   
   observeEvent(input$add2, {
     bs4InsertTab(
       inputId = "tabset2",
       bs4TabPanel(tabName = "Dynamic", "I am inserted and active"),
       target = "Tab 1",
       position = "before",
       select = TRUE
     )
   })
   
 }
 shinyApp(ui, server)
}

bs4Dash

A 'Bootstrap 4' Version of 'shinydashboard'

v0.5.0
GPL (>= 2) | file LICENSE
Authors
David Granjon [aut, cre], RinteRface [cph], Almasaeed Studio [ctb, cph] (AdminLTE3 theme for Bootstrap 4), Winston Chang [ctb, cph] (Utils functions from shinydashboard), Thomas Park [ctb, cph] (Bootswatch Sketchy theme CSS)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.