我在 R (RRO 8.0)中使用闪亮(0.12.0) shinydashboard (0.4.0) .3 CRAN-R 3.1.3)创建UI,我喜欢我所看到的。但是,我希望能够控制dashboardSidebar
项的宽度,因为我需要在那里放置一些宽的选择器框。
ui <- dashboardPage(
dashboardHeader(title = "My Dashboard"),
dashboardSidebar(#stuffhere) #would like a width param setting
dashboardBody()
)
有没有办法做到这一点(一些隐藏得很好的宽度参数,或嵌入式CSS)或者我是否必须回到无聊的光泽并从头开始构建它?
答案 0 :(得分:5)
侧边栏的宽度由.left-side
类上的CSS设置,因此您可以执行以下操作:
dashboardPage(
dashboardHeader(title = "My Dashboard"),
dashboardSidebar( tags$style(HTML("
.main-sidebar{
width: 300px;
}
")),selectInput("id","Select a survey",choices=c("Very very very very long text","text"))),
dashboardBody()
)
答案 1 :(得分:2)
旧答案可能仍然有效,但现在还有一个 width = ...
选项。看:
https://rstudio.github.io/shinydashboard/appearance.html#sidebar-width。这是那里显示的示例代码:
shinyApp(
ui = dashboardPage(
dashboardHeader(
title = "Title and sidebar 350 pixels wide",
titleWidth = 350
),
dashboardSidebar(
width = 350,
sidebarMenu(
menuItem("Menu Item")
)
),
dashboardBody()
),
server = function(input, output) { }
)