首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在闪亮的应用程序中更改shinyWidget的switchInput默认颜色

在闪亮的应用程序中更改shinyWidget的switchInput默认颜色
EN

Stack Overflow用户
提问于 2021-02-03 15:35:30
回答 1查看 524关注 0票数 1

如何更改SwitchInput元素的颜色(从ShinyWidgets包)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-03 15:35:30

首先,在switchInput()函数中,必须通过更改onStatusoffStatus参数来指定"on“和"off”状态:

代码语言:javascript
运行
复制
switchInput(
                       inputId = "switch",
                       label = "Label", 
                       labelWidth = "120px", 
                       onLabel = "ON",
                       offLabel = "OFF",
                       onStatus = "danger",
                       offStatus = "info"
                     ),

然后,在您闪亮的应用程序的UI.r文件或UI部分中,添加以下CSS标记:

代码语言:javascript
运行
复制
#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设置文本颜色。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66030721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档