我使用的是shinythemes库https://rstudio.github.io/shinythemes/,但我想更改单放组按钮的颜色。怎样才能改变颜色呢?
radioGroupButtons(
status = "primary ",
inputId = "indicadores_radiogroup",
choices = c("Casos" = "Confirmados", "Muertes"= "Muertes"),
),谢谢
发布于 2021-03-05 03:24:08
您似乎正在使用shinyWidgets包。可以将status = "danger"设置为红色,或将status = "success"设置为绿色。检查http://shinyapps.dreamrs.fr/shinyWidgets/中的“单选按钮”面板
radioGroupButtons(
inputId = "Id064",
label = "Label",
choices = c("A",
"B", "C", "D"),
status = "danger"
)status参数向按钮添加一个类。该示例为您的按钮提供了btn-danger类。检查关联的css。
.btn-danger {
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
}您可以使用任意字符串来添加自定义类,例如:使用status = 'myClass',按钮将具有类btn-myClass。然后,您将需要指定css。
.btn-myClass {
background-color: #ff4500;
}发布于 2021-03-05 03:34:20
对于您自己的特定颜色,您可以尝试以下方法:
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)https://stackoverflow.com/questions/66481290
复制相似问题