dq_accordion: Accordion module to show several collapsible boxes

Description Usage Arguments Value Author(s) Examples

View source: R/dq_accordion.R

Description

Creates an accordion object where one of the contents can be shown and the others will be hidden. The currently activated panel will be available to R over the input$id element.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dq_accordion(
  id,
  titles,
  contents,
  options = NULL,
  sortable = FALSE,
  bg_color = "#ff8f00",
  hover = TRUE,
  style = "",
  icons = c(rotate = "angle-right")
)

Arguments

id

id of the element

titles

character, titles to show in the accordion headers

contents

list of contents, can be character, shiny tags, nested lists of shiny tags ...

options

optional list of jquery-ui options to customize accordions behavior

sortable

optional logical indicating whether the accordion parts should be rearrangeable or not

bg_color

optional character specifying the background color of the headers, can be any valid HTML color code

hover

optional logical indicating whether headers should have an hover effect or not

style

optional character for additional header style attributes

icons

optional named character vector of length one or two indicating the FontAwesome icons to be used in front of the header title showing the state of the content (open or closed)

Value

shiny div holding the accordion

Author(s)

richard.kunze

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Only run examples in interactive R sessions
if (interactive()) {

library(shiny)
titles <- c("Section 1", "Section 2", "Section 3")
contents <- list("Lorem ipsum..", "Lorem ipsum..", tags$p("Lorem ipsum.."))
shinyApp(
  ui = fluidPage(
    fluidRow(
      column(5, dq_accordion("myAccordion", titles, contents, hover = FALSE,
        style = "border:1px solid red;margin-top: 5px;color: red;"
      ), dq_space(),
      dq_accordion("myAccordion2", titles, contents,
        bg_color = NULL, options = list(animate = 500, collapsible = TRUE),
        icons = c(open = "hand-point-down", closed = "hand-point-right")
      ), dq_space(),
      dq_accordion("myAccordion3", titles, contents,
        bg_color = "pink", icons = NULL, sortable = TRUE
      ))
    )
  ), server = function(input, output) {
    observeEvent(input$myAccordion, print(input$myAccordion))
  }
)

}

daqana/dqshiny documentation built on Sept. 1, 2020, 4:31 p.m.