Description Usage Arguments Details Value Examples
View source: R/accordion_input.R
Create an accordion input element for use in shiny apps. This function
function a component that expands and collapses user defined content. The
component is designed to be selectable i.e., accessible in the shiny
server via input$*
. If you would display content that is collapsible,
use the accordion
component.
1 2 3 4 5 6 7 | accordion_input(
inputId,
title,
content,
checked = FALSE,
class = "accordion__style__a"
)
|
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 |
checked |
a logical argument that indicates if the item should be selected by default (default: FALSE) |
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
|
This component is useful for creating checkbox groups that have further descriptions or other information than may be useful for the user in regards to which element should be selection.
Create an accordion component that is also a checkbox input
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 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("Is Shiny your favorite R technology?"),
iceComponents::accordion_input(
inputId = "what-is-shiny",
title = "Shiny",
checked = TRUE,
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")
)
),
tags$button(
id = "reset",
class = "shiny-bound-input action-button",
"Reset Accordion"
),
tags$button(
id = "clear",
class = "shiny-bound-input action-button",
"Clear Accordion"
)
)
)
server <- function(input, output) {
observeEvent(input$reset, {
iceComponents::reset_accordion_input(inputId = "what-is-shiny")
})
observeEvent(input$clear, {
iceComponents::clear_accordion_input(inputId = "what-is-shiny")
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.