【问题标题】:Change color of notification in R shiny在 R 中更改通知的颜色闪亮
【发布时间】:2020-06-22 09:57:29
【问题描述】:

我正在尝试使用“showNotification”功能来显示绿色弹出窗口。
官方文档说,你可以使用参数'type'来改变颜色。

type    A string which controls the color of the notification. One of "default" (gray), "message" (blue), "warning" (yellow), or "error" (red).

以前有人试过吗?
有没有办法使用 HTML/HEX 代码?

更新
我最终重新着色了单一类型的 showNotifications,如下所示:

 tags$head(tags$style(HTML('
                                                 .shiny-notification-error {
                                                  background-color:#FF5757;
                                                  color:#000000;
                                                 }
                                                  .shiny-notification-message {
                                                  background-color:#B5E26F;
                                                  color:#000000;
                                                 }
                                                 '))),

【问题讨论】:

    标签: r shiny shinywidgets


    【解决方案1】:

    您可以自己添加一些样式:

    library(shiny)
    shinyApp(
      ui = fluidPage(
        tags$head(
          tags$style(
            HTML(".shiny-notification {background-color:#112446;}")
          )
        ),
        actionButton("show", "Show")
      ),
      server = function(input, output) {
        observeEvent(input$show, {
          showNotification("Message text",action = a(href = "javascript:location.reload();", "Reload page"),type = "warning"
          )
        })
      }
    )
    

    【讨论】:

    • 所以这使我所有的弹出窗口都具有相同的颜色,对吧?是否可以将 id 添加到颜色?所以假设你的代码得到了 id 'dark',如果我使用 'type=dark' 弹出窗口变暗,'type=error' 仍然是红色的?
    • 看看shinyBS 包,它有style 功能ebailey78.github.io/shinyBS/docs/Alerts.html
    猜你喜欢
    • 1970-01-01
    • 2018-11-20
    • 2018-04-17
    • 2018-10-22
    • 2020-03-03
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    相关资源
    最近更新 更多