【问题标题】:R shiny input widgetR闪亮的输入小部件
【发布时间】:2021-01-14 04:22:23
【问题描述】:

我可以使用哪种 Shiny 输入小部件来实现图片中的选择器?是否使用了操作按钮?

【问题讨论】:

  • 看看包shinyWidgetsradioGroupButtonshere

标签: r shiny shinydashboard


【解决方案1】:

使用包 shinyWidgets 和一点 CSS,您可以达到相同的效果:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$h1("Active background color for radioGroupButtons"),
  
  tags$style(
    ".btn-custom.active, .btn-custom:active, .btn-custom:focus, .btn-custom:hover {
      background: #4B088A !important;
      color: #FFF !important;
    }",
    ".btn-custom {border-color: #4B088A; color: #4B088A; background: #FFF;}"
  ),
  
  radioGroupButtons(
    inputId = "somevalue",
    label = NULL,
    choices = c("All cases", "Active cases"),
    status = "custom"
  ),
  verbatimTextOutput("value")
)
server <- function(input, output) {
  
  output$value <- renderPrint({ input$somevalue })
  
}
shinyApp(ui, server)

【讨论】:

    【解决方案2】:

    这很可能是一个带有 CSS 样式的 radioButtons 元素。以下是如何将这种格式应用于单选按钮的示例:https://stackoverflow.com/a/4642152/14327549

    【讨论】:

      猜你喜欢
      • 2014-11-12
      • 2018-07-25
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 2015-03-05
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      相关资源
      最近更新 更多