New to Telerik UI for Blazor? Start a free 30-day trial

Display Multiline Text in a Predefined Alert

Updated on Oct 19, 2026

Environment

ProductDialog for Blazor
Version15.0.1 and above

Description

Display a multiline message in a predefined AlertAsync dialog.

Solution

The AlertAsync method accepts a string. Use a verbatim string to include line breaks in the message. The white-space: pre-line rule preserves those line breaks in the predefined Alert.

Example
View Source
<style>
    .k-dialog.k-alert .k-messagebox {
        white-space: pre-line;
    }
</style>

@code {
    [CascadingParameter]
    public DialogFactory? Dialogs { get; set; }

    private async Task ShowMultilineAlert()
    {
        if (Dialogs is not null)
        {
            await Dialogs.AlertAsync(@"Something went wrong!
mammaggia");
        }
    }
}

For HTML or richer content, use the TelerikDialog component and place the content in DialogContent.

See Also