简体   繁体   中英

Change color of notification in R shiny

I am trying to use the funcion "showNotification" to display a green pop up.
The official documentation says, you can use the parameter 'type' to change the color.

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

Has anyone tried this before?
Is there any way to use the HTML/HEX codes?

UPDATE
I ended up re-coloring the single types of showNotifications like this:

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

You can add some style yourself:

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM