如何更改SwitchInput元素的颜色(从ShinyWidgets包)?
发布于 2021-02-03 15:35:30
首先,在switchInput()
函数中,必须通过更改onStatus
和offStatus
参数来指定"on“和"off”状态:
switchInput(
inputId = "switch",
label = "Label",
labelWidth = "120px",
onLabel = "ON",
offLabel = "OFF",
onStatus = "danger",
offStatus = "info"
),
然后,在您闪亮的应用程序的UI.r文件或UI部分中,添加以下CSS标记:
#switchInput color while on
tags$head(tags$style(HTML('.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger,
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger {
background: green;
color: white;
}'))),
#switchInput color while off
tags$head(tags$style(HTML('.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info,
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info {
background: red;
color: black;
}'))),
使用background
设置开关的背景色,使用color
设置文本颜色。
https://stackoverflow.com/questions/66030721
复制相似问题