1

In Shiny is it possible to change the colour of checkboxes from the default blue in the below example?

library("shiny")
server = function(input, output) {

  output$value <- renderPrint({ input$checkGroup })

}

ui = fluidPage(

  checkboxGroupInput("checkGroup", label = h3("Checkbox group"), 
                     choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3),
                     selected = 1),


  hr(),
  fluidRow(column(3, verbatimTextOutput("value")))

)

runApp(list(ui = ui, server = server))
lmsimp
  • 882
  • 7
  • 22

1 Answers1

3

Probably here you may find the answer: https://rstudio.github.io/shinythemes/

The shinythemes package makes it easy to alter the overall appearance of your Shiny applications. For instance:

enter image description here

Also, I would recommend reading this post on styling the checkbox usig CSS: How to style checkbox using CSS?

UPDATE: The below answer references the state of things before widespread availability of CSS3. In modern browsers (including Internet Explorer 9 and later) it is more straightforward to create checkbox replacements with your preferred styling, without using javascript.

Here are some useful links:

It is worth noting that the fundamental issue has not changed. You still can't apply styles (borders, etc.) directly to the checkbox element and have those styles affect the display of the HTML checkbox. What has changed, however, is that it's now possible to hide the actual checkbox and replace it with a styled element of your own, using nothing but CSS. In particular, because CSS now has a widely supported :checked selector, you can make your replacement correctly reflect the checked status of the box.

Denis Rasulev
  • 3,744
  • 4
  • 33
  • 47