Learn R Programming

shinyBS (version 0.20)

collapse: Twitter Bootstrap Collapse Panels

Description

Create Twitter Boostrap-style collapse panels (sometimes called accordion panels) in shiny.

Usage

bsCollapse(..., id = NULL, multiple = FALSE, open = NULL)
bsCollapsePanel(title, ..., id = NULL, value = NULL)
updateCollapse(session, id, open = NULL, close = NULL, multiple = NULL)

Arguments

...
for bsCollapse a series of bsCollapsePanels to include in the object for bsCollapsePanel as series of UI elements to add to the panel
id
a name for the object. Optional
multiple
if TRUE then opening one panel will not close other panels
open
The id of the panel(s) you want to open
close
The id of the panel(s) you want to close
title
The title to appear at the top of the panel
value
The value that is returned by the bsCollapse object when this panel is open
session
The session object passed to function given to shinyServer

Details

bsCollapse works very similarly to tabsetPanel and may be useful in similar situations. Like tabsetPanels, bsCollapse can return values indicating which panels are open or NULL if no panels are open.

References

http://getbootstrap.com/2.3.2/javascript.html{Collapse for Twitter Bootstrap 2.3.2}

Examples

Run this code
## This code, placed inside ui.R, creates the collapse group with 3 panels:
  bsCollapse(multiple = FALSE, open = "col1", id = "collapse1",
            bsCollapsePanel("Collapse #1", "Cell treachery spearwife night\'s 
            watch, tower suckling ...", 
                            id="col1", value="test1"),
            bsCollapsePanel("Collapse #2", actionButton("btn123", "A Button"),
            textInput("txt1234", "A Text Input"), 
                            id="col2", value="test2"),
            bsCollapsePanel("Collapse #3", plotOutput("testPlot1"), 
                            id="col3", value="test3")
            ) 
  
  ## This code, placed inside server.R, will change multiple to TRUE and open 
  ## the first and third panels:
  updateCollapse(session, "collapse1", multiple = TRUE, 
                 open = c("col1", "col2"))

Run the code above in your browser using DataLab