By: Winston Chang
As of version 0.14, Shiny can display notifications on the client browser by using the
showNotification() function. You can see an example of them here.
In this example, we’ll use an
observeEvent() to display the notification when the Show button is pressed:
The notification will appear in the bottom right corner of the browser, remain for 5 seconds, and then fade away.
The are a number options that control the behavior and appearance of notifications
The default color of the notification is gray, but you can use other colors with the
type argument. It can be
"error", which will display as shown below:
By default, a close button will be displayed on the right side of each notification, but it can be removed with
action argument is an additional way of providing content in the notification. The
action UI components will appear underneath the main text. The reason that it is separate is so that it can be custom-styled with CSS.
showNotification() function returns an ID value which can be passed to
removeNotification()to remove the notification from the server side. For example, this application has one button that will present a notification, and another that will remove it:
We love it when R users help each other, but RStudio does not monitor or answer the comments in this thread. If you'd like to get specific help, we recommend the RStudio Community as well as the Shiny Discussion Forum for in depth discussion of Shiny related questions and How to get help article for a list of the best ways to get help with R code.comments powered by Disqus