Table of Contents

Interface ISnackbar

Namespace
MudBlazor
Assembly
MudBlazor.dll

Defines the snackbar service.

public interface ISnackbar : IDisposable
Inherited Members
Extension Methods

Properties

Configuration

The global configuration for each snackbar.

SnackbarConfiguration Configuration { get; }

Property Value

SnackbarConfiguration

ShownSnackbars

The collection of currently shown snackbars.

IEnumerable<Snackbar> ShownSnackbars { get; }

Property Value

IEnumerable<Snackbar>

Methods

Add(MarkupString, Severity, Action<SnackbarOptions>?, string?)

Adds a new snackbar with the specified markup message.

Snackbar? Add(MarkupString message, Severity severity = Severity.Normal, Action<SnackbarOptions>? configure = null, string? key = null)

Parameters

message MarkupString

The markup message to display in the snackbar.

severity Severity

The severity of the snackbar message. Default is Normal.

configure Action<SnackbarOptions>

Optional action to configure the SnackbarOptions.

key string

An optional key to uniquely identify the snackbar. Default is the value of message.

Returns

Snackbar

The created snackbar instance, or null if not created.

Remarks

If a key is provided, this snackbar will not be shown while any snackbar with the same key is being shown.

Add(RenderFragment, Severity, Action<SnackbarOptions>?, string?)

Adds a new snackbar with the specified render fragment.

Snackbar? Add(RenderFragment message, Severity severity = Severity.Normal, Action<SnackbarOptions>? configure = null, string? key = null)

Parameters

message RenderFragment

The render fragment to display in the snackbar.

severity Severity

The severity of the snackbar message. Default is Normal.

configure Action<SnackbarOptions>

Optional action to configure the SnackbarOptions.

key string

An optional key to uniquely identify the snackbar.

Returns

Snackbar

The created snackbar instance, or null if not created.

Remarks

If a key is provided, this snackbar will not be shown while any snackbar with the same key is being shown.

Add(string, Severity, Action<SnackbarOptions>?, string?)

Adds a new snackbar with the specified message.

Snackbar? Add(string message, Severity severity = Severity.Normal, Action<SnackbarOptions>? configure = null, string? key = null)

Parameters

message string

The message to display in the snackbar.

severity Severity

The severity of the snackbar message. Defaults to Normal.

configure Action<SnackbarOptions>

Optional action to configure the SnackbarOptions.

key string

An optional key to uniquely identify the snackbar. Default is the value of message.

Returns

Snackbar

The created snackbar instance, or null if not created.

Remarks

If a key is provided, this snackbar will not be shown while any snackbar with the same key is being shown.

Add<T>(Dictionary<string, object>?, Severity, Action<SnackbarOptions>?, string?)

Adds a new snackbar with the specified component.

Snackbar? Add<T>(Dictionary<string, object>? componentParameters = null, Severity severity = Severity.Normal, Action<SnackbarOptions>? configure = null, string? key = null) where T : IComponent

Parameters

componentParameters Dictionary<string, object>

Optional parameters to pass to the component.

severity Severity

The severity of the snackbar message. Default is Normal.

configure Action<SnackbarOptions>

Optional action to configure the SnackbarOptions.

key string

An optional key to uniquely identify the snackbar.

Returns

Snackbar

The created snackbar instance, or null if not created.

Type Parameters

T

The component type to render inside the snackbar.

Remarks

If a key is provided, this snackbar will not be shown while any snackbar with the same key is being shown.

Clear()

Clears all displayed snackbars.

void Clear()

Remove(Snackbar)

Removes the specified snackbar.

void Remove(Snackbar snackbar)

Parameters

snackbar Snackbar

The snackbar to remove.

RemoveByKey(string)

Removes a snackbar by its key.

void RemoveByKey(string key)

Parameters

key string

The key of the snackbar to remove.

Events

OnSnackbarsUpdated

Event triggered when the collection of shown snackbars is updated.

event Action? OnSnackbarsUpdated

Event Type

Action