notiflix-notify: Notification with notiflix.js

Description Usage Arguments Note Examples

Description

Initialize with use_notiflix_notify in UI before using nx_notify_* server-side.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
nx_notify_success(text, session = shiny::getDefaultReactiveDomain())

nx_notify_error(text, session = shiny::getDefaultReactiveDomain())

nx_notify_info(text, session = shiny::getDefaultReactiveDomain())

nx_notify_warning(text, session = shiny::getDefaultReactiveDomain())

use_notiflix_notify(
  position = c("right-top", "right-bottom", "left-top", "left-bottom"),
  timeout = 3000,
  closeButton = FALSE,
  messageMaxLength = 110,
  width = "280px"
)

Arguments

text

Text to display.

session

Shiny session.

position

Position of notification : "right-top", "right-bottom", "left-top", "left-bottom".

timeout

Milliseconds to hide the Notifications. Tip: 3000 ms = 3 seconds.

closeButton

If you want to add a close button to notifications you can set this option to TRUE (Notifications with close button will not disappear until they are clicked.)

messageMaxLength

Ignores characters of the message text after the specified number.

width

Changes the width. You can use "px" or "%". Default to "280px".

Note

Configuration of notification is done with use_notiflix_notify in UI per application.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(shiny)
library(shinypop)

ui <- fluidPage(
  tags$h2("Notification with notiflix.js"),
  use_notiflix_notify(position = "right-bottom"),
  actionButton("success", "Show success", class = "btn-success"),
  actionButton("error", "Show error", class = "btn-danger"),
  actionButton("info", "Show info", class = "btn-info"),
  actionButton("warning", "Show warning", class = "btn-warning")
)

server <- function(input, output, session) {
  
  observeEvent(input$success, {
    nx_notify_success("Yes :)")
  })
  
  observeEvent(input$error, {
    nx_notify_error("Oups...")
  })
  
  observeEvent(input$info, {
    nx_notify_info("For information")
  })
  
  observeEvent(input$warning, {
    nx_notify_warning("Careful !!!")
  })
  
}

if (interactive()) 
  shinyApp(ui, server)

dreamRs/shinypop documentation built on Oct. 18, 2021, 8:28 p.m.