Description Usage Arguments Examples
Insert a tabPanel in a tabsetPanel
1 2 3 4 5 6 7 8 |
inputId |
tabsetPanel id. |
tab |
tabPanel to insert. |
target |
tabPanel after of before which the new tab will be inserted. |
position |
Insert before or after: |
select |
Whether to select the newly inserted tab. FALSE by default. |
session |
Shiny session object. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
title = "Handle tabs",
body = dashboardBody(
actionButton("add", "Add 'Dynamic' tab"),
actionButton("remove", "Remove 'Foo' tab"),
actionButton("hideTab", "Hide 'Foo' tab"),
actionButton("showTab", "Show 'Foo' tab"),
br(), br(),
tabBox(
id = "tabs",
title = "A card with tabs",
selected = "Bar",
status = "primary",
solidHeader = FALSE,
type = "tabs",
tabPanel("Hello", "This is the hello tab"),
tabPanel("Foo", "This is the foo tab"),
tabPanel("Bar", "This is the bar tab")
)
)
),
server = function(input, output, session) {
observeEvent(input$add, {
insertTab(
inputId = "tabs",
tabPanel("Dynamic", "This a dynamically-added tab"),
target = "Bar",
select = TRUE
)
})
observeEvent(input$remove, {
removeTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$hideTab, {
hideTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$showTab, {
showTab(inputId = "tabs", target = "Foo")
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.