Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
daattali opened this issue Feb 18, 2017 · 7 comments
Open
Labels

Comments

@daattali
Copy link

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
Copy link
Owner

I agree!

@daattali
Copy link
Author

daattali commented Jul 4, 2017

@ijlyttle this is the blocker for me :)

@ijlyttle
Copy link
Owner

ijlyttle commented Jul 6, 2017

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

@ijlyttle ijlyttle added the 0.1.3 label Jul 16, 2017
@Patanouque
Copy link

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
Copy link

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
Copy link

warnes commented Jan 6, 2023

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
Copy link

warnes commented Jan 6, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants