你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

huangapple go评论83阅读模式
英文:

How can I change the font color of an accordion menu in a shiny app?

问题

I want to recreate the following accordion menu:
你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am using the accordion() function from the shinydashboardPlus package, and got to here so far:
你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am trying to change the font color to black to match the first image, but adding the following CSS code is not working:

tags$head(
    tags$style(
        HTML(".box-title {
          color: black !important;
        }")
    )
)

If someone could help me to change the font color, and if possible to add the well (AKA: the white rectangle with circled borders around each item of the accordion menu) it would be great!

Here is the full app code:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- fluidPage(
  tags$head(
    tags$style(
      HTML(".box-title {
          color: black !important;
      }")
    )
  ),
  accordion(
    id = "covenants",
    accordionItem(
      title = "Cash on cash",
      status = "danger",
      collapsed = TRUE,
      "This is some text!"
    ),
    accordionItem(
      title = "Net Portfolio Yield Percentage",
      status = "warning",
      collapsed = TRUE,
      "This is some text!"
    ),
    accordionItem(
      title = "Minimum Liquidity Amount",
      status = "warning",
      collapsed = TRUE,
      "This is some text!"
    ),
    accordionItem(
      title = "Maximum Debt to Equity Ratio",
      status = "warning",
      collapsed = TRUE,
      "This is some text!"
    ),
    accordionItem(
      title = "Most Favored Nation",
      status = "warning",
      collapsed = TRUE,
      "This is some text!"
    )
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)
英文:

I want to recreate the following accordion menu: 你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am using the accordion() function from the shinydashboardPlus package, and got to here so far:

你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am trying to change the font color to black to match the first image, but adding the following CSS code is not working:

tags$head(
    tags$style(
      HTML(&quot;
        .box-title {
          color: black !important;
        }
      &quot;)
    )
  )

If someone could help me to change the font color, and if possible to add the well (AKA: the white rectangle with circled borders around each item of the accordion menu) it would be great!

Here is te full app code:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui &lt;- fluidPage(
  tags$head(
    tags$style(
      HTML(&quot;
        .box-title {
          color: black !important;
        }
      &quot;)
    )
  ),
  accordion(
    id = &quot;covenants&quot;,
    accordionItem(
      title = &quot;Cash on cash&quot;,
      status = &quot;danger&quot;,
      collapsed = TRUE,
      &quot;This is some text!&quot;
    ),
    accordionItem(
      title = &quot;Net Portfolio Yield Percentage&quot;,
      status = &quot;warning&quot;,
      collapsed = TRUE,
      &quot;This is some text!&quot;
    ),
    accordionItem(
      title = &quot;Minimum Liquidity Amount&quot;,
      status = &quot;warning&quot;,
      collapsed = TRUE,
      &quot;This is some text!&quot;
    ),
    accordionItem(
      title = &quot;Maximum Debt to Equity Ratio&quot;,
      status = &quot;warning&quot;,
      collapsed = TRUE,
      &quot;This is some text!&quot;
    ),
    accordionItem(
      title = &quot;Most Favored Nation&quot;,
      status = &quot;warning&quot;,
      collapsed = TRUE,
      &quot;This is some text!&quot;
    )
  )
)

server &lt;- function(input, output, session) {}

shinyApp(ui, server)


答案1

得分: 0

.box-title选择器针对手风琴的标题,通常是一个超链接。默认情况下,超链接具有特殊样式,包括不同颜色的已访问和未访问链接。color属性仅适用于未访问链接,而:visited选择器可用于定位已访问链接。

因此,正确的CSS代码是:

.box-title a {
  color: black !important;
}
英文:

The .box-title selector targets the title of the accordion, which is usually a hyperlink. By default, hyperlinks have a special style that includes a different color for visited and unvisited links. The color property only applies to unvisited links, whereas the :visited selector can be used to target visited links

Therefore, the correct CSS code is:

.box-title a {
  color: black !important;
}

huangapple
  • 本文由 发表于 2023年4月11日 01:18:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979190.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定