Notifications are pop-up messages displayed to inform users about activities, processes, and events in the application.

To show a notification, inject the Notifications bean into the view class and use its fluent interface. In the following example, a notification with default parameters is shown on the button click:

private Notifications notifications;

public void onHelloButtonClick(ClickEvent<Button> event) {"Hello");

Below is an example of a parameterized notification:


To display HTML content in a notification, pass the com.vaadin.flow.component.Html component to the show() or create() method. The content should have exactly one root element. For example: Html("<div>Hello<br>World</div>"));

You can also display a multi-line text using \n characters and a special CSS class:

notifications.create("First line\nSecond line")