collapseBox | R Documentation |
A custom collapsible box with Shiny inputs upon collapse, more or less stolen from shinyBS.
collapseBox(id, title, ..., open = FALSE, style = NULL)
id |
String specifying the identifier for this object, to use as a field of the Shiny input. |
title |
String specifying the title of the box for use in the UI. |
... |
Additional UI elements to show inside the box. |
open |
Logical scalar indicating whether this box should be open upon initialization. |
style |
String specifying the box style, defaults to |
Collapsible boxes are used to hold parameters in the “parameter boxes” described in .defineInterface
.
It is recommended to format the id
as PANEL_SLOT
where PANEL
is the name of the panel associated with the box and SLOT
is the name of the slot that specifies whether this box should be open or not at initialization.
(See Panel for some examples with DataBoxOpen
.)
Do not confuse these boxes with the shinydashboard::box
es, which are used to hold the plot and table panels.
Adding to the nomenclature confusion is the fact that our collapsible boxes are implemented in Javascript using the Bootstrap “panel” classes, which in turn has nothing to do with our Panel classes.
A HTML tag object containing a collapsible box.
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 a Depends:
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 in inst/www
and is attached to the search path for Shiny resources upon loading iSEE.
Aaron Lun
shinyBS, from which the Javascript code was derived.
.defineInterface
, which should return a list of these collapsible boxes.
library(shiny)
collapseBox("SomePanelType1_ParamBoxOpen",
title="Custom parameters",
open=FALSE,
selectInput("SomePanelType1_Thing",
label="What thing?",
choices=LETTERS, selected="A"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.