4

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;
                                                 }
                                                 '))),

1 Answers1

5

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

enter image description here

Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • So this makes all my popups the same colour, right? Is it possible to add an id to a color? so lets say your code gets the id 'dark' and if i use 'type=dark' the popup gets dark, 'type=error' still is red? – areNg aka areNg Mar 10 '20 at 14:25
  • 1
    Have a look at the `shinyBS` package, which has `style` feature https://ebailey78.github.io/shinyBS/docs/Alerts.html – Pork Chop Mar 10 '20 at 14:29