Skip to content

Allow multiple panels to be open at one time #112

Description

@warnes

I need to allow multiple panels to be open at one time.

The attached file provides the function bs_multi_open, which modifies the HTML generated by bs_accordion to (1) enable/disable multiple panels to be open at one time and (2) specify which (if any) panels are initially open.

This solves #35.

bs_multi_open.txt

Example use:

shinyApp(
ui = fluidPage(

   tags$h2("Multiple Open Panels, Panels 1 and 3 open at page load"),
   bs_accordion(id = "beatles") %>%
     bs_set_opts(panel_type = "success", use_heading_link = TRUE) %>%
     bs_append(title = "John Lennon", content = "Rhythm guitar, vocals") %>%
     bs_append(title = "Paul McCartney", content = "Bass guitar, vocals") %>%
     bs_append(title = "George Harrison", content = "Lead guitar, vocals") %>%
     bs_append(title = "Ringo Starr", content = "Drums, vocals") %>%
     bs_multi_open(
       multi=TRUE,
       open=c(1,3)
       ),

   tags$h2("One Open Panel, No panels open on page load."),
   bs_accordion(id = "fruit") %>%
     bs_set_opts(panel_type = "info") %>%
     bs_append(title = "Apples", content = "An apple a day keeps the doctor away.") %>%
     bs_append(title = "Bannana", content = "Watch out for bannana peels!") %>%
     bs_append(title = "Kumquat", content = "What is a kumquat?!") %>%
     bs_multi_open(
       multi=FALSE,
       open=c()
      )
   ),
     
 server = function(input, output) {}
 )

Which yields:
image

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions