Toast

Short-lived notification messages — variants, subtitle, icon, auto-hide and custom body content.

Basic

Html.Toast() renders a Bootstrap toast. SetTitle and SetMessage provide the header and body text.

Basic toast

C#
@using DMBBootstrapBuilder
@using DMBPageBuilder
@using (Html.BlockBuilder().AddClass("toast-container position-static d-flex flex-column gap-2").Begin())
{
    @(Html.Toast().SetTitle("File saved").SetMessage("Your document has been saved successfully.").Render())
    @(Html.Toast().SetMessage("Settings have been updated.").Render())
}

Variants

SetVariant(VariantStyle) colours the toast header — the same set available on alerts and modals.

Variants

C#
@using DMBBootstrapBuilder
@using DMBPageBuilder
@using (Html.BlockBuilder().AddClass("toast-container position-static d-flex flex-column gap-2").Begin())
{
    @(Html.Toast().SetTitle("Saved").SetMessage("All changes persisted.").SetVariant(VariantStyle.Success).Render())
    @(Html.Toast().SetTitle("Error").SetMessage("Upload failed — please retry.").SetVariant(VariantStyle.Danger).Render())
}

Subtitle & Icon

SetSubtitle(string) adds a small timestamp or context label. SetIcon(IconStruct) places an icon in the header.

Subtitle & icon

C#
@using DMBBootstrapBuilder
@using DMBPageBuilder
@using (Html.BlockBuilder().AddClass("toast-container position-static d-flex flex-column gap-2").Begin())
{
    @(Html.Toast().SetTitle("New comment").SetSubtitle("2 min ago").SetMessage("Alice replied to your post.").SetVariant(VariantStyle.Primary).Render())
    @(Html.Toast().SetTitle("Deployment finished").SetSubtitle("just now").SetMessage("Version 2.4.1 is live on production.").SetVariant(VariantStyle.Success).SetIcon(IconStruct.Bootstrap("bi-cloud-check")).Render())
}

Auto-hide

SetAutoHide(false) keeps the toast visible until the user closes it — useful when a decision is required.

Auto-hide

C#
@using DMBBootstrapBuilder
@using DMBPageBuilder
@using (Html.BlockBuilder().AddClass("toast-container position-static d-flex flex-column gap-2").Begin())
{
    @(Html.Toast().SetTitle("Upload complete").SetMessage("3 files have been uploaded.").SetVariant(VariantStyle.Success).SetIcon(IconStruct.Bootstrap("bi-upload")).Render())
    @(Html.Toast().SetTitle("Action required").SetMessage("You must confirm before the changes are applied.").SetVariant(VariantStyle.Warning).SetIcon(IconStruct.Bootstrap("bi-exclamation-triangle")).SetAutoHide(false).Render())
}

Custom body

.Begin() switches to wrapping mode — any HTML or builder content placed inside replaces the default message body.

Custom body

C#
@using DMBBootstrapBuilder
@using DMBPageBuilder
@using (Html.BlockBuilder().AddClass("toast-container position-static").Begin())
{
    @using (Html.Toast().SetTitle("Publication queue").SetSubtitle("2 min ago").SetIcon(IconStruct.Bootstrap("bi-cloud-upload")).SetVariant(VariantStyle.Info).Begin())
    {
        @using (Html.BlockBuilder().AddClass("d-flex flex-column gap-2").Begin())
        {
            @using (Html.BlockBuilder().Begin())
            {
                @:3 documentation pages are waiting for publication.
            }
            @Html.ProgressBar().SetValue(66).SetVariant(VariantStyle.Info)
        }
    }
}