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
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
Dense
Gets or sets a value indicating whether the alert should use compact padding.
[Parameter]
public bool Dense { get; set; }
Property Value
Dismissed
Gets or sets a value indicating whether the alert is currently dismissed (hidden).
[Parameter]
public bool Dismissed { get; set; }
Property Value
DismissedChanged
Gets or sets the callback that is invoked when the Dismissed state changes.
[Parameter]
public EventCallback<bool> DismissedChanged { get; set; }
Property Value
Dismissible
Gets or sets a value indicating whether the alert can be dismissed by the user.
[Parameter]
public bool Dismissible { get; set; }
Property Value
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?
EndIconPadding
Gets or sets the Tailwind padding classes between the text and the end icon. Defaults to the theme's small padding when not set.
[Parameter]
public string? EndIconPadding { get; set; }
Property Value
OnDismiss
Gets or sets the callback that is invoked when the alert is dismissed.
[Parameter]
public EventCallback OnDismiss { get; set; }
Property Value
Role
Gets or sets the ARIA role of the alert, which decides how a screen reader announces it.
[Parameter]
public string? Role { get; set; }
Property Value
Remarks
Leave unset for the default: alert (announced at once, interrupting) for
Danger and Warning, and status
(announced when the screen reader is idle) for every other color. Set none for an alert that
is part of the page from the start and should be read in place like any other content.
StartIcon
Gets or sets the icon to display at the start of the alert.
[Parameter]
public Icon? StartIcon { get; set; }
Property Value
- Icon?
StartIconPadding
Gets or sets the Tailwind padding classes between the start icon and the text. Defaults to the theme's small padding when not set.
[Parameter]
public string? StartIconPadding { get; set; }
Property Value
Text
Gets or sets the text content to display in the alert.
[Parameter]
public string? Text { get; set; }
Property Value
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
__builderRenderTreeBuilder