-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathshow_toast.R
80 lines (71 loc) · 1.41 KB
/
show_toast.R
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Sweet Alert Toast"),
actionButton(
inputId = "toast",
label = "Show default toast"
),
actionButton(
inputId = "success",
label = "Show success toast",
icon = icon("check")
),
actionButton(
inputId = "error",
label = "Show error toast",
icon = icon("xmark")
),
actionButton(
inputId = "warning",
label = "Show warning toast",
icon = icon("triangle-exclamation")
),
actionButton(
inputId = "info",
label = "Show info toast",
icon = icon("info")
)
)
server <- function(input, output, session) {
observeEvent(input$toast, {
show_toast(
title = "Notification",
text = "An imortant message"
)
})
observeEvent(input$success, {
show_toast(
title = "Bravo",
text = "Well done!",
type = "success"
)
})
observeEvent(input$error, {
show_toast(
title = "Ooops",
text = "It's broken",
type = "error",
width = "800px",
position = "bottom"
)
})
observeEvent(input$warning, {
show_toast(
title = "Careful!",
text = "Almost broken",
type = "warning",
position = "top-end"
)
})
observeEvent(input$info, {
show_toast(
title = "Heads up",
text = "Just a message",
type = "info",
position = "top-end"
)
})
}
if (interactive())
shinyApp(ui, server)