Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<Demo Type="typeof(Toasts_Demo_02_Toast_Without_Title)" />
</Section>

<Section Size="HeadingSize.H2" Name="Toast with templated content" PageUrl="@pageUrl" Link="toast-with-content">
<Demo Type="typeof(Toasts_Demo_07_Toast_With_Content)" />
</Section>

<Section Size="HeadingSize.H2" Name="Auto hide" PageUrl="@pageUrl" Link="auto-hide">
<div>Add <code>AutoHide="true"</code> parameter to hide the Blazor Toasts after the delay. The default delay is 5000 milliseconds, be sure to update the delay timeout so that users have enough time to read the toast.</div>
<Demo Type="typeof(Toasts_Demo_03_A_Auto_Hide)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Toasts class="p-3" Messages="messages" />

<Button Class="btn btn-primary" @onclick="ShowToast">Toast with Content</Button>

@code {
List<ToastMessage> messages = [];

private void ShowToast() =>
messages.Add(
new ToastMessage
{
Type = ToastType.Info,
Title = "Blazor Bootstrap",
Content = @<div>Hello, world! This is a toast message. <button class="btn btn-sm btn-primary mt-2" @onclick="ShowToast">Show more toast</button></div>,
});
}
1 change: 1 addition & 0 deletions blazorbootstrap/Components/Toasts/SimpleToast.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div class="d-flex">
<div class="toast-body">
@ToastMessage?.Message
@ToastMessage?.Content
</div>
@if (!AutoHide || ShowCloseButton)
{
Expand Down
1 change: 1 addition & 0 deletions blazorbootstrap/Components/Toasts/Toast.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
<div class="toast-body">
@ToastMessage.Message
@ToastMessage.Content
</div>
<Progress Height="3">
<ProgressBar @ref="toastProgressBar" Color="@progressColor" Width="toastProgressBarWidth"/>
Expand Down
2 changes: 2 additions & 0 deletions blazorbootstrap/Models/ToastMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public ToastMessage(ToastType type, string customIconName, string title, string

public string? Message { get; set; }

public RenderFragment? Content { get; set; }

public string? Title { get; set; }

public ToastType Type { get; set; }
Expand Down
Loading