Description Usage Arguments Author(s) Examples
Imported by bs4TabCard but can be used alone. This is a modified shiny::tabsetPanel, to handle bootstrap 4. This function will be upgraded starting from shiny 1.7.0 (support Bootstrap 4 tabs).
1 2 3 4 5 6 7 8 9 10 |
... |
|
id |
If provided, you can use |
selected |
The |
type |
|
position |
This argument is deprecated; it has been discontinued in Bootstrap 3. |
vertical |
Whether to displays tabs vertically. Default to FALSE. |
side |
Tabs side: |
.list |
In case of programmatically generated items. See example. |
David Granjon, dgranjon@ymail.com
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | if(interactive()){
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
title = "Bootstrap 4 tabsetPanel",
body = dashboardBody(
# manually inserted panels
tabsetPanel(
id = "tabcard",
tabPanel(
title = "Tab 1",
"Content 1"
),
tabPanel(
title = "Tab 2",
"Content 2"
),
tabPanel(
title = "Tab 3",
"Content 3"
)
),
br(), br(),
# programmatically inserted panels
tabsetPanel(
id = "tabset",
.list = lapply(1:3, function(i) {
tabPanel(
title = paste0("Tab", i),
active = FALSE,
paste("Content", i)
)
})
)
)
),
server = function(input, output) {}
)
# update tabsetPanel
shinyApp(
ui = dashboardPage(
title = "updateTabsetPanel",
header = dashboardHeader(),
body = dashboardBody(
tabsetPanel(
id = "tabset1",
selected = "Tab 2",
tabPanel(
title = "Tab 1",
numericInput("val", "Value:", 10, min = 1, max = 100),
verbatimTextOutput("value")
),
tabPanel(
title = "Tab 2",
"Content 2"
),
tabPanel(
title = "Tab 3",
checkboxGroupInput(
inline = TRUE,
"variable", "Variables to show:",
c("Cylinders" = "cyl",
"Transmission" = "am",
"Gears" = "gear")
),
tableOutput("data")
)
),
uiOutput("tabSetPanel2")
),
sidebar = dashboardSidebar(
skin = "light",
sliderInput(
inputId = "controller",
label = "Update the first tabset",
min = 1,
max = 3,
value = 2
),
br(),
sliderInput(
inputId = "controller2",
label = "Update the second tabset",
min = 1,
max = 3,
value = 3
)
),
controlbar = dashboardControlbar(collapsed = FALSE),
footer = dashboardFooter()
),
server = function(input, output, session) {
output$tabSetPanel2 <- renderUI({
tabsetPanel(
id = "tabset2",
tabPanel(
title = "Tab 1",
p("Tab 1 ")
),
tabPanel(
title = "Tab 2",
p("Tab 2")
),
tabPanel(
title = "Tab 3",
p("Tab 3")
)
)
})
# update tabset1
observeEvent(input$controller, {
updateTabsetPanel(
session,
inputId = "tabset1",
selected = paste("Tab", input$controller)
)
}, ignoreInit = TRUE)
# update tabset 2
observeEvent(input$controller2, {
updateTabsetPanel(
session,
inputId = "tabset2",
selected = paste("Tab", input$controller2)
)
}, ignoreInit = TRUE)
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
output$data <- renderTable({
mtcars[, c("mpg", input$variable), drop = FALSE]
}, rownames = TRUE)
output$txt <- renderText({
paste("You chose", input$rb)
})
output$value <- renderText({ input$val })
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.