forked from MudBlazor/MudBlazor
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Programatically removing a Snackbar (MudBlazor#5016)
* added documentation for programatically remove snackbar * updated text and highligthing
- Loading branch information
1 parent
7e6ee9a
commit 56202c8
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/MudBlazor.Docs/Pages/Components/Snackbar/Examples/SnackbarRemoveExample.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@namespace MudBlazor.Docs.Examples | ||
|
||
@inject ISnackbar Snackbar | ||
|
||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@Show"> | ||
Open Snackbar | ||
</MudButton> | ||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@Hide"> | ||
Hide snackbar | ||
</MudButton> | ||
|
||
@code { | ||
private Snackbar _snackbar; | ||
|
||
void Show() | ||
{ | ||
_snackbar = Snackbar.Add("Now click hide snackbar", Severity.Normal, config => | ||
{ | ||
config.VisibleStateDuration = int.MaxValue; | ||
}); | ||
} | ||
|
||
void Hide() { | ||
if (_snackbar is null) return; | ||
Snackbar.Remove(_snackbar); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters