简体   繁体   中英

Shinydashboard dashboardSidebar Width Setting

I'm using shiny (0.12.0) with shinydashboard (0.4.0) in R (RRO 8.0.3 CRAN-R 3.1.3) to create a UI, and I'm liking what I'm seeing. However, I would like to be able to control the width of the dashboardSidebar item, since I need to put some wide selector boxes in there.

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

Is there a way to do it (some well-hidden width parameter, or embedded css) or do I have to go back to boring shiny and build it from the ground up instead?

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

The width of the sidebar is set by CSS on the .left-side class, so you could do:

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()
  )

The old answer might still work, but there is also a width = ... option now. See: https://rstudio.github.io/shinydashboard/appearance.html#sidebar-width . Here is the example code shown over there:

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) { }
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM