首页 > 解决方案 > 从 shinyWidgets 更改下拉按钮的 css 参数

问题描述

我从 shinyWidgets 包中设计了一个简单的下拉按钮。不知何故,我无法更改小部件的 css 参数。

dropdownButton( icon = icon('info'), size = 'sm', right = T, up = F, width = '400px',
              div('my text', style = 'font-size:10px'))

我已经尝试按照这里shinywidget dropdownButton CSS标签的链接的css调整

然而,这只改变了弹出窗口的参数。

我试图检查元素并找到 css 代码但徒劳无功。

理想情况下,我需要更改按钮的大小、背景颜色和不透明度。

谢谢

标签: rshiny

解决方案


希望这会有所帮助,参考这个 SO 链接#1,'status' 参数可以让你设置自定义类(见这个)。在 tags$style 中,您可以使用 'background-color' 选择背景颜色,使用 'opacity' 选择不透明度。'size' 参数允许您选择按钮的大小。

dropdownButton(status = "dropdownbutton", icon = icon('info'), size = "lg", right = T, up = F, width = '400px',
                div('my text', style = 'font-size:10px')
               ),
tags$head(tags$style(
  "
  .btn-dropdownbutton{
                      background-color: #393D3F !important;
                      border: solid; border-radius: 4px; border-width: 1px; border-color:#339FFF;
                      color: #339FFF; text-align: center; font-weight:bold; font-size: 12px;
                      opacity: 0.5 !important;
    }
  "

推荐阅读