【发布时间】:2018-11-30 15:03:27
【问题描述】:
有人知道如何在选中闪亮按钮时突出显示边框或颜色吗?
请在下面找到一个可复制的示例
library(shiny)
ui <- fluidPage(
actionButton(inputId = "button1", label = "Select red"),
actionButton(inputId = "button2", label = "Select blue"),
plotOutput("distPlot")
)
server <- function(input, output) {
r <- reactiveValues(my_color = "green")
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x))
hist(x, breaks = bins, col = r$my_color)
})
observeEvent(input$button1, {
r$my_color <- "red"
})
observeEvent(input$button2, {
r$my_color <- "blue"
})
}
shinyApp(ui = ui, server = server)
以下是上面代码的结果:
这是我在选择“选择红色”按钮时想要得到的(请注意,它应该在选择时突出显示另一个):
如果这不可能,是否存在在选择时更改按钮颜色的方法?
提前致谢
【问题讨论】:
标签: r button shiny shinydashboard highlighting