Class SnackbarService
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
public class SnackbarService : ISnackbar, IDisposable
- Inheritance
-
SnackbarService
- Implements
- Inherited Members
- Extension Methods
Constructors
SnackbarService(NavigationManager, IOptions<SnackbarConfiguration>)
public SnackbarService(NavigationManager navigationManager, IOptions<SnackbarConfiguration> configuration = null)
Parameters
navigationManager
NavigationManagerconfiguration
IOptions<SnackbarConfiguration>
Properties
Configuration
public SnackbarConfiguration Configuration { get; }
Property Value
ShownSnackbars
public IEnumerable<Snackbar> ShownSnackbars { get; }
Property Value
Methods
Add(MarkupString, Severity, Action<SnackbarOptions>, string)
Displays a snackbar containing the text/HTML.
public Snackbar Add(MarkupString message, Severity severity = Severity.Normal, Action<SnackbarOptions> configure = null, string key = "")
Parameters
message
MarkupStringSpecifies the content of the snackbar.
severity
SeverityThe severity of the snackbar. Dictates the color and default icon of the notification.
configure
Action<SnackbarOptions>Additional configuration for the snackbar.
key
stringIf no key is passed, defaults to the content of the message. This message will not be shown while any other message with the same key is being shown.
Returns
- Snackbar
The snackbar created by the parameters.
Add(RenderFragment, Severity, Action<SnackbarOptions>, string)
Displays a snackbar containing the RenderFragment.
public Snackbar Add(RenderFragment message, Severity severity = Severity.Normal, Action<SnackbarOptions> configure = null, string key = "")
Parameters
message
RenderFragmentThe RenderFragment which specifies the content of the snackbar.
severity
SeverityThe severity of the snackbar. Dictates the color and default icon of the notification.
configure
Action<SnackbarOptions>Additional configuration for the snackbar.
key
stringIf a key is provided, this message will not be shown while any other message with the same key is being shown.
Returns
- Snackbar
The snackbar created by the parameters.
Add(string, Severity, Action<SnackbarOptions>, string)
Displays a snackbar containing the text.
public Snackbar Add(string message, Severity severity = Severity.Normal, Action<SnackbarOptions> configure = null, string key = "")
Parameters
message
stringThe string which specifies the content of the snackbar.
severity
SeverityThe severity of the snackbar. Dictates the color and default icon of the notification.
configure
Action<SnackbarOptions>Additional configuration for the snackbar.
key
stringIf no key is passed, defaults to the content of the message. This message will not be shown while any other message with the same key is being shown.
Returns
- Snackbar
The snackbar created by the parameters.
Add<T>(Dictionary<string, object>, Severity, Action<SnackbarOptions>, string)
Displays a snackbar containing a custom component specified by T.
public Snackbar Add<T>(Dictionary<string, object> componentParameters = null, Severity severity = Severity.Normal, Action<SnackbarOptions> configure = null, string key = "") where T : IComponent
Parameters
componentParameters
Dictionary<string, object>Any additional parameters needed by the custom component to display the message.
severity
SeverityThe severity of the snackbar. Dictates the color and default icon of the notification.
configure
Action<SnackbarOptions>Additional configuration for the snackbar.
key
stringIf a key is provided, this message will not be shown while any other message with the same key is being shown.
Returns
- Snackbar
The snackbar created by the parameters.
Type Parameters
T
The type of the custom component that specifies the content of the snackbar.
Clear()
public void Clear()
Dispose()
public void Dispose()
Remove(Snackbar)
public void Remove(Snackbar snackbar)
Parameters
snackbar
Snackbar
RemoveByKey(string)
public void RemoveByKey(string key)
Parameters
key
string
Events
OnSnackbarsUpdated
public event Action OnSnackbarsUpdated