Search code examples
cssrwidthshiny

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?

Sad skinny panel needs more meat


Solution

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