bs_accordion {bsTools}R Documentation

Create a Bootstrap accordion

Description

Learn more at https://getbootstrap.com/docs/5.1/components/accordion/.

Usage

bs_accordion(
  id,
  items = list(),
  expand = c(),
  button_background_color = NULL,
  button_text_color = NULL,
  accordion_attr = list(class = "accordion"),
  item_attr = list(class = "accordion-item"),
  item_header_attr = list(class = "accordion-header"),
  button_attr = list(class = "accordion-button collapsed"),
  div_attr = list(class = "accordion-collapse collapse"),
  body_attr = list(class = "accordion-body")
)

Arguments

id

A string, the id to use for the accordion, must be unique within a page (if you have multiple accordions on a page).

items

A named list, names become the label for each panel, values should be the HTML content to display when the panel is toggled.

expand

A vector, the names or positions of panels that should be expanded by default.

button_background_color

A string vector, the color to apply to the background of the accordion toggle button. Recycles for each panel.

button_text_color

A string vector, the color to apply to the text of the accordion toggle button. Recycles for each panel.

accordion_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion content.

item_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion items.

item_header_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the accordion panel headers.

button_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the accordion panel header button items.

div_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion panel content.

body_attr

A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion panel content body.

Value

A string of HTML.

Examples

bs_accordion(
id = "acc1",
items = list(
  "One" = p("Check it out."),
  "Two" = p("Does it work?"),
  "Three" = p("I hope so.")
)
)

[Package bsTools version 1.0.5 Index]