没有侧边栏面板的可折叠盒子/几个可折叠或手风琴作为侧边栏

问题描述

我想创建一个 Shiny 应用,其中包含多个 collapsible 框作为一侧的菜单。为此,到目前为止,我使用了 bsCollapsePanel 函数并将其放入 sidebarPanel。不幸的是,我从盒子到 sidebarPanel 有额外的边距。盒子看起来很衬托。但我只想使用可折叠框作为侧边栏。

到目前为止,我已经使用了以下解决方案:

library(shinythemes)
library(shinyBS)

fluidPage(
  theme = shinytheme("cosmo"),titlePanel(# app title/description
    "ShinyApp"),sidebarLayout(
    mainPanel(plotOutput("plot1")),sidebarPanel(
      bsCollapsePanel(
        "Color Selection",actionButton("f1blue","Blue"),actionButton("f1red","Red"),actionButton("f2blue",actionButton("f2red",style = "success"
      ),)
   
  )
)

这是图形输出:

enter image description here

这就是它的样子。我想避免这种“盒子中的盒子”效应。侧边栏面板中只有可折叠项,没有边框和边距:

enter image description here

是否有解决方案和/或另一个包更适合创建可折叠/手风琴?

我很感激任何建议!

解决方法

这个怎么样:

library(shinythemes)
library(shinyBS)

ui <- fluidPage(
    theme = shinytheme("cosmo"),tags$style('#sidebar {border: none; background-color: transparent; padding: 0;}'),titlePanel(# app title/description
        "ShinyApp"),sidebarLayout(
        mainPanel(plotOutput("plot1")),sidebarPanel(
            id = "sidebar",bsCollapsePanel(
                "Color Selection",actionButton("f1blue","Blue"),actionButton("f1red","Red"),actionButton("f2blue",actionButton("f2red",style = "success"
            ),style = "success"
            )
        )
        
    )
)
server <- function(input,output,session) {
    output$plot1 <- renderPlot(plot(1))
}

shinyApp(ui = ui,server = server)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...