A custom collapsible box with Shiny inputs upon collapse, more or less stolen from shinyBS.
collapseBox(id, title, ..., open = FALSE, style = NULL)
String specifying the identifier for this object, to use as a field of the Shiny input.
String specifying the title of the box for use in the UI.
Additional UI elements to show inside the box.
Logical scalar indicating whether this box should be open upon initialization.
String specifying the box style, defaults to "default"
.
A HTML tag object containing a collapsible box.
shinyBS, from which the Javascript code was derived.
library(shiny)
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
fluidRow(
column(width=6L, collapseBox(
id="collapseBox_001",
title="Collapsible box",
open=FALSE,
p("A simple paragraph."),
selectInput("selectInput_001",
label="Select a letter",
choices=LETTERS, selected="A"
)
)),
column(width=6L, p(
"On the left is an example of a", code("collapseBox"), ".", br(),
"Click on the title of the box to expand or collapse its contents."
))
)
)
shinyApp(ui, server = function(input, output) { })
}
Comments on shinyBS
We would have preferred to use
bsCollapse
from shinyBS. However, that package does not seem to be under active maintenance, and there are several aspects that make it difficult to use. Specifically, it does not seem to behave well with conditional elements inside the box, and it also does needs aDepends:
relationship with shinyBS.For these reasons, we created our own collapsible box, taking code from
shinyBS
where appropriate. The underlying Javascript code for this object is present ininst/www
and is attached to the search path for Shiny resources upon loading iSEE.