accordion: 'accordion'

Description Usage Arguments Value Examples

View source: R/accordion.R

Description

Create an accordion element for use in shiny apps. This function returns a component that expands and collapses user defined content. For example, you can create an FAQ page using this component, create definitions, or hide anything you like. The returned component is a text element (i.e., title, question, etc.) and an html element (or tagList containing) two or more html elements.

Usage

1
2
3
4
5
6
7
accordion(
  inputId,
  title,
  content,
  heading_level = "h3",
  class = "accordion__style__a"
)

Arguments

inputId

a unique ID for the accordion component

title

a text string containing a title for the collapsible section

content

an html element or a list of html elements

heading_level

adjust the HTML heading level; default is "h3". Use on of the following headings: h1, h2, h3, h4, h5, h6

class

a string containing css classes. Using this argument, you can pass your own class names or use one of the classes made available by this package: "accordion__style__a" (styling used in the app). Use "class = NULL", to return a minimally styled component.

Notes on heading_level: By default, the title is rendered into a h3 element. This element may not always work in all situations as it is difficult to determine the markup and context the accordion element is used. This option will allow you to use the accordion element with the document's hierarchy All html heading elements can be used (h1, h2, ..., or h6).

Value

Create an accordion component

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
27
28
29
30
31
32
33
34
35
36
if (interactive()) {
  library(shiny)
  ui <- tagList(
    iceComponents::use_iceComponents(),
    tags$head(
      tags$style(
        "#what-is-shiny {
           width: 400px;
        }"
      )
    ),
    tags$main(
      id = "main",
      class = "main",
      tags$h2("Frequently Asked Questions Page"),
      tags$p("Here are some commonly asked questions"),
      iceComponents::accordion(
        inputId = "what-is-shiny",
        title = "What is Shiny?",
        content = tagList(
          tags$p(
            "Shiny is an R package that makes it easy to build",
            "interactive web apps straight from R. You can host",
            "standalone apps on a webpage or embed them in R Markdown",
            "documents or build dashboards. You can also extend your",
            "Shiny apps with CSS themes, htmlwidgets, and JavaScript",
            "actions."
          ),
          tags$cite("Rstudio.org")
        )
      )
    )
  )
  server <- function(input, output) {}
  shinyApp(ui, server)
}

InControlofEffects/iceComponents documentation built on April 1, 2021, 5:51 a.m.