Search code examples
rshinyshinydashboardshinywidgets

How to override actionbttn color in shinywidget package?


actionbttn in shinywidget package only have several option for its button color. How do I change it into other color that is not provided by default?


Solution

  • For example, I have this actionBttn wrapped in div() for further CSS styling :

    div(class = "buttonagency",
    actionBttn(inputId = "button.agency", label = "Agency",
    style = "jelly", color = "primary",size = "sm"))
    

    I chose "primary" as my default color. It doesn't matter which default color that you choose, as long as you choose one.

    At the end of my UI, I add tags$style() for all CSS styling that I use in my shiny dashboard. To change the button color, I wrote down CSS style addresing first the button's CSS class, .bttn, and the default color that I chose, followed by whatever color I want it to change into. It looks like this:

    .buttonagency .bttn-primary{background-color: red;}
    

    Hope it helps.