https://github.com/JohnCoene/awn
Awesome notifications for shiny
https://github.com/JohnCoene/awn
Last synced: 24 days ago
JSON representation
Awesome notifications for shiny
- Host: GitHub
- URL: https://github.com/JohnCoene/awn
- Owner: JohnCoene
- License: other
- Created: 2021-08-12T20:47:10.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-10T14:59:02.000Z (3 months ago)
- Last Synced: 2025-04-19T07:58:22.133Z (about 1 month ago)
- Language: R
- Size: 99.6 KB
- Stars: 25
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - awn - Awesome Notifications for Shiny. (UI Components / Feedback / Alert / Notification)
- jimsghstars - JohnCoene/awn - Awesome notifications for shiny (R)
README
# awn
[Awesome notifications](https://f3oall.github.io/awesome-notifications/) for shiny.
## Installation
Install from Github.
``` r
# install.packages("remotes")
remotes::install_github("JohnCoene/awn")
```## Demo
Run the `gallery` to view a demo app and the functionalities of
the package.```r
awn::gallery()
```### Notify
Show a notification.
Place `useAwn` in the UI.```r
library(awn)
library(shiny)ui <- fluidPage(
useAwn(),
actionButton("show", "Show")
)server <- function(input, output, session) {
observeEvent(input$show, {
type <- sample(
c("tip", "info", "warning", "success", "alert"),
1
)notify(
"Hello {awn}!",
type = type
)
})}
shinyApp(ui, server)
```### Modal
Display a modal. Place `useAwn` in the UI.
```r
library(awn)
library(shiny)ui <- fluidPage(
useAwn(),
actionButton("show", "Show")
)server <- function(input, output, session) {
observeEvent(input$show, {
modal(
h1("Hello {awn}!")
)
})}
shinyApp(ui, server)
```### Ask
Prompt the user.
Place `useAwn` in the UI.```r
library(awn)
library(shiny)ui <- fluidPage(
useAwn(),
actionButton("show", "Show")
)server <- function(input, output, session) {
observeEvent(input$show, {
ask(
"confirmed", # id of input
p("Are you sure?")
)
})observeEvent(input$confirmed, {
print(input$confirmed)
})}
shinyApp(ui, server)
```## Options
There are numerous [options](https://f3oall.github.io/awesome-notifications/docs/customization/) that are
not hard-coded but nonetheless accessible.You can also define global options to avoid
having to repeat options at every notification, modal,
etc.```r
library(awn)
library(shiny)ui <- fluidPage(
useAwn(),
actionButton("show", "Show")
)server <- function(input, output, session) {
awn_globals(durations = list(tip = 10000))
observeEvent(input$show, {
notify(
"Hello {awn}!",
type = "tip",
labels = list(
tip = "ADVICE"
)
)
})}
shinyApp(ui, server)
```