collapseBox: A collapsible box

View source: R/collapseBox.R

collapseBoxR Documentation

A collapsible box

Description

A custom collapsible box with Shiny inputs upon collapse, more or less stolen from shinyBS.

Usage

collapseBox(id, title, ..., open = FALSE, style = NULL)

Arguments

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 "default".

Details

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::boxes, 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.

Value

A HTML tag object containing a collapsible box.

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 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.

Author(s)

Aaron Lun

See Also

shinyBS, from which the Javascript code was derived.

.defineInterface, which should return a list of these collapsible boxes.

Examples

library(shiny)
collapseBox("SomePanelType1_ParamBoxOpen",
    title="Custom parameters",
    open=FALSE,
    selectInput("SomePanelType1_Thing",
        label="What thing?",
        choices=LETTERS, selected="A"
    )
)


csoneson/SEE documentation built on Oct. 13, 2024, 10:19 a.m.