rshinyshinybsbslib

How do i use bscollapse with a theme in rshiny?


I am creating a shiny app and I want information to appear in a drop down panel.

I am using BSCollapse to do this. It works fine but when I try and add a theme the bscollapsepanels no longer work as they should.

Can you help?

This is an example of the code that i am trying to run


library(shiny)
library(shinyBS)

shinyApp(
  ui =
    fluidPage(
        theme = bs_theme(bg = "white",
                         fg = "black",
                         primary = "#00a499",
                         base_font = font_google("Prompt"),
                         code_font = font_google("JetBrains Mono")),
        mainPanel(
          bsCollapse(id = "collapseExample", open = "Panel 2",
                     bsCollapsePanel("Panel 1", "This is a panel with just text ",
                                     "and has the default style. You can change the style in ",
                                     "the sidebar."),
                     bsCollapsePanel("Panel 2", "This panel has a generic plot. ",
                                     "and a 'success' style.", plotOutput("genericPlot"), style = "success")
          )
        )
    ),
  server =
    function(input, output, session) {
      output$genericPlot <- renderPlot(plot(rnorm(100)))

    }
)

Solution

  • The shinyBS package has been conceived for Bootstrap 3. You can specify this version of Bootstrap in bs_theme and it works:

    bs_theme(version = 3, bg = "white", ......