gpt4 book ai didi

html - 为 checkboxGroupInput 选择着色

转载 作者:行者123 更新时间:2023-11-28 05:16:31 24 4
gpt4 key购买 nike

在我的 Shiny UI 中有

ui <- checkboxGroupInput("my_cbgi", "Choose Something", c("A", "B", "C", "D"))

我希望选项(文本)A 和 B 为红色,但 C 和 D 不是。我尝试了 HTML,但随后在 UI 中出现了诸如“attribs”和“children”之类的奇怪框。

提前致谢

最佳答案

shiny_1.0.1 以来,checkboxGroupInput 有一个 choiceNameschoiceValues 参数用于传递任意 UI 以显示用户,检查这个例子:

library("shiny")

ui <- fluidPage(
checkboxGroupInput(
inputId = "my_cbgi",
label = "Choose Something",
choiceNames = list(
tags$span("A", style = "color: red;"),
tags$span("B", style = "color: red;"),
tags$span("C", style = "color: blue;"),
tags$span("D", style = "font-weight: bold;")
),
choiceValues = c("A", "B", "C", "D")
)
)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)

关于html - 为 checkboxGroupInput 选择着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44958495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com