accordionItem.Rd
`accordionItem` allows to create new accordion item that can be passed directly to `accordion` constructor or added on the fly with `addAccordionItem`.
accordionItem(
id,
header,
content,
class = NULL,
enroll_callback = TRUE,
active = FALSE,
header_class = NULL,
content_class = NULL,
...
)
addAccordionItem(
accordionId,
accordionItem,
session = shiny::getDefaultReactiveDomain()
)
Unique id of accordion item.
Accordion item header.
Accordion item content.
Class passed to accordion container.
It `TRUE`, click action on header will enroll the accordion item (and collapse the other existing ones). See accordionEnrollOnClick to see how configure custom on-click enroll element.
Should item be enrolled?
Additional class passed to header container.
Additional class passed to content container.
Extra elements passed to accordion container (before the first accordion item).
Id of accordion component where item should be added.
Accordion item to be added.
Shiny Session object.
Nested list of `shiny.tag` objects, defining accordion item - its header and content, or no return value in case of using `addAccordionItem` method.
if (interactive()) {
library(shiny)
ui <- fluidPage(
actionButton("new", "New"),
accordion(
"acc",
accordionItem("first", "Hello", "There", active = TRUE),
accordionItem("second", "General", "Kenobi")
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
# Accordion with custom styling of header and content (and dynamically added items).
library(shiny)
styled_item <- function(id, header_text, content_text, active = FALSE) {
accordionItem(
id, header_text, content_text, active = active,
header_class = "acc-header", content_class = "acc-content"
)
}
ui <- fluidPage(
tags$head(tags$style(
".acc-header, .acc-content {border: 1px solid; border-radius: 5px;}"
)),
actionButton("new", "New"),
accordion(
"acc",
styled_item("first", "Hello", "There", TRUE),
styled_item("second", "General Kenobi", "There")
)
)
server <- function(input, output, session) {
observeEvent(input$new, {
addAccordionItem(
"acc",
styled_item(
sample(letters, 1), "I've Been Trained In Your Jedi Arts",
"By Count Dooku", TRUE
)
)
})
}
shinyApp(ui, server)
}