modify CSS of specific individual Input's

1,311 views
Skip to first unread message

mts...@gmail.com

unread,
Dec 26, 2015, 5:11:26 PM12/26/15
to Shiny - Web Framework for R
I want to have one large selectInput at the top of my app, but then have other selectINputs the default.

I can change the selectInput css so they are all updated, but how would I modify the css of just one select input

This will update all selectInput's:


runApp(shinyApp(
  ui = fluidPage(
    tags$style(type='text/css', ".selectize-input { font-size: 32px; line-height: 32px;} .selectize-dropdown { font-size: 28px; line-height: 28px; }"),
    selectInput("test","Test", 1:5)
  ),
  server = function(input, output, session) {
  }
))



how can I make it for just a specific input, I tried something like this: (doesn't work)

selectInput2<-function (inputId, label, choices,selected) 
{
  tags$style(type='text/css', ".selectize-input { font-size: 32px; line-height: 32px;} .selectize-dropdown { font-size: 28px; line-height: 28px; }")
  
  selectInput2<-selectInput(inputId=inputId, label=label, choices=choices,selected=selected) 
 return(selectInput2)
}


ui = fluidPage(
  selectInput2('test','Test',choices=1:5,selected=3),
  
  selectInput('test2','Test',choices=1:5,selected=3)

)


Thanks!!!

Anestis Fachantidis

unread,
Dec 27, 2015, 6:52:12 AM12/27/15
to Shiny - Web Framework for R
Hi, it can be done, I think it would be better to have an external css file and keep there all these css rules and modifications, see here : (includecss)
http://shiny.rstudio.com/articles/css.html

now find the exact css element "address" of this select box using e.g. F12 - inspect element in your browser and pointing to it, then you make a new css rule for this specific element

example: for a select box named cmbMain a css rule in an external css file could be like this :

html body div.container-fluid div.container-fluid div.row-fluid h4 select#cmbMain.shiny-bound-input{width: 600px;margin-bottom: 5px;border-radius:30px;height: 50px;
line-height:50px;}

Reply all
Reply to author
Forward
0 new messages