簡體   English   中英

更改 R 中通知的顏色閃亮

[英]Change color of notification in R shiny

我正在嘗試使用功能“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;
                                                 }
                                                 '))),

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

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"
      )
    })
  }
)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM