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:
If you have questions about this article or would like to discuss ideas presented here, please post on RStudio Community. Our developers monitor these forums and answer questions periodically. See help for more help with all things Shiny.