首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在R Shiny中修改select input中多个选定值的显示

如何在R Shiny中修改select input中多个选定值的显示
EN

Stack Overflow用户
提问于 2020-10-27 01:25:31
回答 1查看 306关注 0票数 0

我构建了一个具有多选输入的Shinyapp。一切正常,但当我选择多个值时,

This is the ugly box I'm talking about

有没有一种方法可以格式化所选值的显示?也许只是在带有选项的下拉列表中打勾,或者类似的东西?

EN

回答 1

Stack Overflow用户

发布于 2020-10-27 03:06:39

您可以使用此css更改选择框中项目的颜色

代码语言:javascript
运行
复制
.selectize-control.multi .selectize-input > div {
        background: #d8544c;
        color: #fdfdfd;
}

示例应用程序的代码:

代码语言:javascript
运行
复制
library(shiny)

ui <- fluidPage(
    tags$head(
        tags$style(HTML("
        
      .selectize-control.multi .selectize-input > div {
        background: #d8544c;
        color: #fdfdfd;
}

    "))
    ),
    sidebarLayout(
        sidebarPanel(
            selectInput("select1",
                        "Choices:",
                        choices = names(mtcars), multiple = TRUE)
        ),
    mainPanel(
        verbatimTextOutput("out")
        )
    )
)

server <- function(input, output) {
    output$out <- renderPrint({
      input$select1
    })
}

shinyApp(ui = ui, server = server)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64542030

复制
相关文章

相似问题

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