ijlyttle / bsplus

Shiny and R Markdown addons to Bootstrap 3
http://ijlyttle.github.io/bsplus/
Other
146 stars 23 forks source link

Request: ability to create an accordion that is collapsed initially #35

Open daattali opened 7 years ago

daattali commented 7 years ago

It'd be nice to be able to do something like

library(shiny)
library(bsplus)

ui <- fluidPage(
  bs_accordion(id = "foo") %>%
    bs_append(title = "bar", content = "hello world", selected = FALSE)
)

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

}

shinyApp(ui = ui, server = server)

so that the accordion will initialize in a collapsed state

ijlyttle commented 7 years ago

I agree!

daattali commented 7 years ago

@ijlyttle this is the blocker for me :)

ijlyttle commented 7 years ago

There are a couple ways to go about this - including your suggestion. I'll bug you about which you may think may be best.

Patanouque commented 5 years ago

You can remove the "in" class of the first element of the accordion by doing :

attrib_ = my_accordion$children[[1]]$children[[2]]$attribs
attrib_[which(attrib_ == "in")] = NULL
my_accordion$children[[1]]$children[[2]]$attribs = attrib_

Not very clean but it does the job

tconwell commented 4 years ago

I am unsuccessfully trying to do the same thing using something like this: bs_accordion(id = a_id) %>% bs_set_aria("div", multiselectable = TRUE, expanded = FALSE) %>% bs_append(title = paste(p_title, "Exposure", sep = " "),

Do you have any advice on how to best have the panels default as closed?

warnes commented 1 year ago

I just uploaded a function bs_multi_open in #112 that allows you to control which (if any) of the panels are initially open, as well as enabling/disabling multiple open panels.

warnes commented 1 year ago

Now available in PR #133 via the function bs_accordion_multi. The man page example demonstrates this (also shown in the comments to PR #113).