Collection of notifications and dialogs for Shiny applications
You can install dev version from GitHub:
remotes::install_github("dreamRs/shinypop")
Notifications libraries included :
- noty : https://github.com/needim/noty
- notie : https://github.com/jaredreich/notie
- push : https://github.com/Nickersoft/push.js
- notiflix : https://github.com/notiflix/Notiflix
- vex : https://github.hubspot.com/vex/docs/welcome/
Notifications with various themes and options to configure :
ui <- fluidPage(
tags$h2("noty example"),
use_noty(),
actionButton(
inputId = "show",
label = "Show notification"
)
)
server <- function(input, output, session) {
observeEvent(input$show, {
noty(text = "Hello world!", type = "info")
})
}
shinyApp(ui, server)
Top or bottom full width notifications :
ui <- fluidPage(
tags$h2("notie example"),
use_notie(),
actionButton(
inputId = "show",
label = "Show notification",
width = "100%"
)
)
server <- function(input, output, session) {
observeEvent(input$show, {
notie(
text = "Hello world!",
type = "info",
position = "bottom"
)
})
}
shinyApp(ui, server)
push.js allow to create desktop notification (outside the browser), user must allow this type of notification.
ui <- fluidPage(
tags$h2("Push notification"),
use_push(),
actionButton("show", "Show notification"),
textInput("title", "Text to display", "Hello world :)")
)
server <- function(input, output, session) {
observeEvent(input$show, {
push(title = input$title)
})
}
shinyApp(ui, server)
Fully configurable notifications :
ui <- fluidPage(
tags$h2("Notification with notiflix.jx"),
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 !!!")
})
}
shinyApp(ui, server)
Confirmation dialogs can be done with :
- notie : https://github.com/jaredreich/notie
- notiflix : https://github.com/notiflix/Notiflix
Ask user confirmation :
ui <- fluidPage(
use_notie(),
tags$h2("notie.js confirmation pop-up"),
actionButton("show", "Ask for confirmation"),
verbatimTextOutput("result")
)
server <- function(input, output, session) {
observeEvent(input$show, {
notie_confirm(
inputId = "confirm",
text = "Do you want to confirm?",
label_submit = "Sure!",
label_cancel = "Nope!"
)
})
output$result <- renderPrint({
input$confirm
})
}
shinyApp(ui, server)
Ask user confirmation :
ui <- fluidPage(
use_notiflix_confirm(),
tags$h2("notiflix confirmation pop-up"),
actionButton("show", "Ask for confirmation"),
verbatimTextOutput("result")
)
server <- function(input, output, session) {
observeEvent(input$show, {
nx_confirm(
inputId = "confirm",
title = "Do you want to confirm?",
button_ok = "Sure!",
button_cancel = "Nope!"
)
})
output$result <- renderPrint({
input$confirm
})
}
shinyApp(ui, server)
For alerts you can use :
- notiflix : https://github.com/notiflix/Notiflix
- vex: https://github.com/hubspot/vex
Show an alert :
ui <- fluidPage(
tags$h2("Reports with notiflix.jx"),
use_notiflix_report(),
actionButton("success", "Show success", class = "btn-success")
)
server <- function(input, output, session) {
observeEvent(input$success, {
nx_report_success("Bravo!", "Everything worked as expected")
})
}
shinyApp(ui, server)
Those packages include similar functionnalities :
shinyalert
allow to use sweetalertshinyWidgets
allow to use sweetalert2shinytoastr
allow to use toastr