I am using the library shinythemes https://rstudio.github.io/shinythemes/ but I would like to change the color of radiogroup buttons. How can I change the color?
radioGroupButtons(
status = "primary ",
inputId = "indicadores_radiogroup",
choices = c("Casos" = "Confirmados", "Muertes"= "Muertes"),
),
Thanks
It seems you are using the shinyWidgets
package. You can set status = "danger"
for a red color, or status = "success"
for a green color. Check the ' radio Buttons' panel in http://shinyapps.dreamrs.fr/shinyWidgets/
radioGroupButtons(
inputId = "Id064",
label = "Label",
choices = c("A",
"B", "C", "D"),
status = "danger"
)
The status
parameter adds a class to your button. The example gives your button the class btn-danger
. Check the css associated.
.btn-danger {
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
}
You can use an arbitrary string to add a custom class, eg : with status = 'myClass'
, buttons will have class btn-myClass
. Then you will need to specify the css.
.btn-myClass {
background-color: #ff4500;
}
For your own specific color, you can try the following:
ui = fluidPage(
radioGroupButtons(
#status = "primary ", ## you can change status value to change to select few colors
inputId = "indicadores_radiogroup",
checkIcon = list(yes = icon("check")),
choiceValues = c("Confirmados", "Muertes"),
choiceNames = c("Casos", "Muertes"),
justified = TRUE, width = "300px"
),
tags$script("$(\"input:radio[name='indicadores_radiogroup'][value='Confirmados']\").parent().css('background-color', '#FF4500');"),
tags$script("$(\"input:radio[name='indicadores_radiogroup'][value='Muertes']\").parent().css('background-color', '#7EF373');"),
)
server = function(...) {}
shinyApp(ui, server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.