Shinydashboard仪表板侧栏宽度设置

Ser*_*asa 3 css r width shiny

我在R(RRO 8.0.3 CRAN-R 3.1.3)中使用闪亮(0.12.0)和shinydashboard(0.4.0 )来创建UI,我喜欢我所看到的.但是,我希望能够控制项目的宽度,因为我需要在那里放置一些宽的选择器框.dashboardSidebar

ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard"),
  dashboardSidebar(#stuffhere)  #would like a width param setting
  dashboardBody()
)
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点(一些隐藏的宽度参数,或嵌入式CSS)或者我是否必须回到无聊的闪亮并从头开始构建它?

悲伤的瘦面板需要更多的肉

she*_*heß 12

旧的答案可能仍然有效,但现在还有一个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) { }
)
Run Code Online (Sandbox Code Playgroud)


Nic*_*icE 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()
  )
Run Code Online (Sandbox Code Playgroud)

  • 为了让一切看起来正确,我不得不将以下css添加到`dashboardBody`函数:`tags $ head(tags $ style(HTML('.main-sidebar {width:300px;} .main-header> .navbar {margin-left:300px;} .main-header .logo {width:300px;} .content-wrapper,.main-footer,.right-side {margin-left:300px;}')))` (3认同)