Skip to contents

This function inserts a accordion

Usage

accordion(inputId, titles, descriptions)

Arguments

inputId

Input Id for the accordion

titles

Add the titles for the accordion

descriptions

Add the main content for each accordion section. Each item accepts a plain character string (rendered as a govuk-body paragraph), or shiny tag objects and shiny::tagList() values for richer block content such as multiple paragraphs, lists, or links. Tag content is inserted as-is and is not wrapped in a govuk-body paragraph, so build rich content from the styled helpers, shinyGovstyle::gov_text() for paragraphs and shinyGovstyle::gov_list() for lists, to keep GOV.UK styling. A bare tag or string passed without those helpers will render without govuk-body styling.

Value

an accordion HTML shiny tag object

See also

Other Govstyle tables tabs and accordions: govReactable(), govReactable-shiny, govTable(), govTabs()

Examples

ui <- shiny::fluidPage(
  shinyGovstyle::header(
    org_name = "Example",
    service_name = "User Examples",
    logo = "shinyGovstyle/images/moj_logo.png",
    logo_alt_text = "Ministry of Justice logo"
  ),
  shinyGovstyle::banner(
    inputId = "banner", type = "beta", 'This is a new service'
  ),
  shinyGovstyle::gov_layout(
    size = "two-thirds",
    accordion(
      "acc1",
      c(
        "Writing well for the web",
        "Writing well for specialists",
        "Know your audience",
        "How people read"
      ),
      list(
        "This is the content for Writing well for the web.",
        "This is the content for Writing well for specialists.",
        "This is the content for Know your audience.",
        # Rich content: a paragraph followed by a bulleted list with a link
        shiny::tagList(
          shinyGovstyle::gov_text(
            "People read in different ways, including:"
          ),
          shinyGovstyle::gov_list(
            list(
              "scanning for key words",
              shiny::tags$a(href = "https://www.gov.uk", "following links")
            ),
            style = "bullet"
          )
        )
      )
    )
  ),
  shinyGovstyle::footer(full = TRUE)
)

server <- function(input, output, session) {}

if (interactive()) shiny::shinyApp(ui = ui, server = server)