Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shinydashboard dashboardSidebar Width Setting

Tags:

css

r

width

shiny

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

like image 381
Serban Tanasa Avatar asked May 20 '15 13:05

Serban Tanasa


2 Answers

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()
  )
like image 71
NicE Avatar answered Nov 18 '22 09:11

NicE


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) { }
)
like image 26
sheß Avatar answered Nov 18 '22 11:11

sheß