【问题标题】:Collapsible boxes without sidebar panel / several collapsibles or accordions as sidebar没有侧边栏面板的可折叠盒子/几个可折叠或手风琴作为侧边栏
【发布时间】:2021-09-23 10:51:59
【问题描述】:

我想创建一个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", "Blue"),
        actionButton("f2red", "Red"),
        style = "success"
      ),
      
     
    )
   
  )
)

这是图形输出:

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

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

感谢您的任何建议!

【问题讨论】:

标签: r shiny accordion fluid-layout shinybs


【解决方案1】:

这个怎么样:

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", "Blue"),
                actionButton("f2red", "Red"),
                style = "success"
            ),
            bsCollapsePanel(
                "Color Selection",
                actionButton("f1blue", "Blue"),
                actionButton("f1red", "Red"),
                actionButton("f2blue", "Blue"),
                actionButton("f2red", "Red"),
                style = "success"
            )
        )
        
    )
)
server <- function(input, output, session) {
    output$plot1 <- renderPlot(plot(1))
}

shinyApp(ui = ui, server = server)

【讨论】:

    猜你喜欢
    • 2016-11-14
    • 2014-06-20
    • 1970-01-01
    • 1970-01-01
    • 2019-11-13
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 2017-05-29
    相关资源
    最近更新 更多