Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sliderInput in Shiny -- how to control the length/width of the slider in shiny?

When i use the sliderInput function in shiny it seems like I am not able to control the width/length of the slider. By default, the slider occupies the entire width of the page (in basicPage mode, not in the pageWithSidebar mode). I am wondering if there is some way to control the width of the slider. Thanks for any suggestions.

like image 294
BlasIyer Avatar asked Jun 06 '13 19:06

BlasIyer


2 Answers

It is possible to add a style tag in ui.r:

tags$head(
      tags$style(type="text/css", ".jslider { max-width: 200px; }")
    ),

Place these lines inside shinyUI() and the width of the sliderinput can be adjusted.

UPDATE:
With Shiny 0.11 RStudio switched from jslider to irs (http://cran.r-project.org/web/packages/shiny/NEWS):

Changed sliders from jquery-slider to ion.rangeSlider. These sliders have an improved appearance, support updating more properties from the server, and can be controlled with keyboard input. Which means .jslider won't work any more.

Change to .irs {max-width: 200px;} should work.

like image 98
Timror Avatar answered Oct 08 '22 17:10

Timror


Timrors answer did not work for me. However, there is an argument width=NULL in sliderInput(), which is documented as follows:

The width of the sliderInput, e.g. '400px', or '100%'; see validateCssUnit.

Setting it to 100% creates a sliderInput spannign the entire row, etc.

like image 21
Julian Avatar answered Oct 08 '22 15:10

Julian