Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reduce the height of shiny input widgets?

Tags:

r

shiny

In a shiny dashboard app, I want to put several (>5) slider inputs inside a box that has a specific height. The height argument in box() only seems to control the height of the box itself, and the contents (sliders) spill out below the box. How can I make the sliders smaller so that they will all fit inside the box? ( I have other things to fit in the page). Heres my example ui:

dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
      fluidRow(
      box(title="inputs",height="200px",
          sliderInput("in1","1",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in2","2",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in3","3",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in4","4",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in5","5",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in6","6",min = 0,max = 1, step=0.01,value = 0),
          sliderInput("in7","7",min = 0,max = 1, step=0.01,value = 0)
      )
  )))

Making all the labels NULL helps a bit, but ideally I could have more control over the size/height (and have labels).

Thanks for any tips.

like image 291
jim Avatar asked May 04 '15 01:05

jim


1 Answers

I've discovered that the height of a widget can be changed by putting it inside a div() and setting the height there:

div(style="height: 27px;",
        sliderInput("in1",NULL,min = 0,max = 1, step=0.05,value = 0,ticks=F))

It seems it should also be possible (and more efficient?) to do this with tags, e.g. https://groups.google.com/forum/#!msg/shiny-discuss/3m7cq96mcBY/OEICaO_7Na0J, but I can't make that work.

like image 128
jim Avatar answered Oct 22 '22 12:10

jim