Skip to content

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

Open

Description

@daattali

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

Activity

  1. ijlyttle commented on Feb 18, 2017

    @ijlyttle
    Owner

    I agree!

  2. daattali commented on Jul 4, 2017

    @daattali
    Author

    @ijlyttle this is the blocker for me :)

  3. ijlyttle commented on Jul 6, 2017

    @ijlyttle
    Owner

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

  4. Patanouque commented on Jun 20, 2019

    @Patanouque

    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

  5. tconwell commented on Apr 21, 2020

    @tconwell

    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?

  6. warnes commented on Jan 6, 2023

    @warnes

    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.

  7. warnes commented on Jan 6, 2023

    @warnes

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions