Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bs_accordion

Accordion panel-group


Description

An accordion is a set of collapsible panels where, at most, one panel-body is visible.

Usage

bs_accordion(id)

## S3 method for class 'bsplus_accordion'
bs_append(tag, title, content, ...)

## S3 method for class 'bsplus_accordion'
bs_set_opts(tag, panel_type = "primary", use_heading_link = TRUE, ...)

Arguments

id

character, unique id for accordion <div/>, also serves as root id for panels appended using bs_append()

tag

htmltools::[tag][htmltools::tag], accordion <div/> to which to append a panel

title

character (HTML) or htmltools::[tagList][htmltools::tagList], title for the panel heading

content

character (HTML) or htmltools::[tagList][htmltools::tagList], content for the panel body

...

other arguments (not used)

panel_type

character, one of the standard Bootstrap types c("default", "primary", "success", "info", "warning", "danger")

use_heading_link

logical, indicates whether to make the entire panel heading clickable.

Details

All of these functions return a bsplus_accordion object (which is also an htmltools::[tag][htmltools::tag], <div/>), so you can compose an accordion by piping. There are three parts to this system:

  1. A constructor function for the accordion, bs_accordion()

  2. A function to set options for subsequent panels, bs_set_opts()

  3. A function to append a panel to the group, bs_append()

The verb append is used to signify that you can append an arbitrary number of panels to an accordion.

For the constructor, bs_accordion(), it is your responsibility to ensure that id is unique among HTML elements in your page. If you have non-unique id's, strange things may happen to your page.

Value

bsplus_accordion object (htmltools::[tag][htmltools::tag], <div/>)

See Also

Examples

bs_accordion(id = "meet_the_beatles") %>%
  bs_set_opts(panel_type = "success", use_heading_link = TRUE) %>%
  bs_append(title = "John Lennon", content = "Rhythm guitar, vocals") %>%
  bs_set_opts(panel_type = "info") %>%
  bs_append(title = "Paul McCartney", content = "Bass guitar, vocals")

bsplus

Adds Functionality to the R Markdown + Shiny Bootstrap Framework

v0.1.2
MIT + file LICENSE
Authors
Ian Lyttle [aut, cre, cph] (<https://orcid.org/0000-0001-9962-4849>), Schneider Electric [cph], Alex Shum [ctb], Emily Bosak [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.