Table of Contents

Class TwAlert

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents an alert component that displays informational messages to users.

public class TwAlert : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
Inheritance
TwAlert
Implements
Inherited Members

Remarks

The TwAlert component is a flexible notification element that can display text or custom content with optional icons and a dismissible close button. It supports various color schemes through the Color parameter and can be shown or hidden using the Dismissed parameter.

Constructors

TwAlert()

public TwAlert()

Properties

ChildContent

Gets or sets the custom content to display in the alert.

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

Remarks

When provided, this content replaces the Text parameter.

Color

Gets or sets the color scheme for the alert.

[Parameter]
public Color? Color { get; set; }

Property Value

Color?

Dense

Gets or sets a value indicating whether the alert should use compact padding.

[Parameter]
public bool Dense { get; set; }

Property Value

bool

Dismissed

Gets or sets a value indicating whether the alert is currently dismissed (hidden).

[Parameter]
public bool Dismissed { get; set; }

Property Value

bool

DismissedChanged

Gets or sets the callback that is invoked when the Dismissed state changes.

[Parameter]
public EventCallback<bool> DismissedChanged { get; set; }

Property Value

EventCallback<bool>

Dismissible

Gets or sets a value indicating whether the alert can be dismissed by the user.

[Parameter]
public bool Dismissible { get; set; }

Property Value

bool

Remarks

When set to true, a close button will be displayed that allows the user to dismiss the alert.

EndIcon

Gets or sets the icon to display at the end of the alert.

[Parameter]
public Icon? EndIcon { get; set; }

Property Value

Icon?

OnDismiss

Gets or sets the callback that is invoked when the alert is dismissed.

[Parameter]
public EventCallback OnDismiss { get; set; }

Property Value

EventCallback

StartIcon

Gets or sets the icon to display at the start of the alert.

[Parameter]
public Icon? StartIcon { get; set; }

Property Value

Icon?

Text

Gets or sets the text content to display in the alert.

[Parameter]
public string? Text { get; set; }

Property Value

string

Remarks

This text is displayed when no ChildContent is provided. If both Text and ChildContent are set, ChildContent takes precedence.

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder