Alert
A callout that draws attention to a message.
Examples
Variants
Heads up
Solid alert in the primary color.
Deployed
Your changes are live.
Quota almost reached
80% of your plan is used.
Payment failed
Update your card to keep your plan.
Razor
<div class="flex w-full max-w-xl flex-col gap-3">
<KlyAlert Title="Heads up" Description="Solid alert in the primary color." />
<KlyAlert Title="Deployed" Description="Your changes are live." Color="KlyColor.Success" Variant="KlyVariant.Subtle" Icon='KlyIcons.Named("circle-check")' />
<KlyAlert Title="Quota almost reached" Description="80% of your plan is used." Color="KlyColor.Warning" Variant="KlyVariant.Soft" Icon='KlyIcons.Named("triangle-alert")' />
<KlyAlert Title="Payment failed" Description="Update your card to keep your plan." Color="KlyColor.Error" Variant="KlyVariant.Outline" Icon='KlyIcons.Named("circle-x")' />
</div>Actions and close
A new version is available
Reload to get the latest features.
Razor
<div class="w-full max-w-xl">
<KlyAlert Title="A new version is available" Description="Reload to get the latest features." Color="KlyColor.Info" Variant="KlyVariant.Subtle"
Icon='KlyIcons.Named("info")' Close>
<Actions>
<KlyButton Label="Reload" Size="KlySize.Xs" Color="KlyColor.Info" />
</Actions>
</KlyAlert>
</div>Details, action items and live region
Details sits behind a Show details toggle, ActionItems draws KlyActionItem records, StatusIcon shows the icon of the color and Live (Polite or Assertive) makes it a live region for an alert inserted after the page loaded.
Quota warning
Your plan is almost full.
Razor
<div class="w-full max-w-xl">
<KlyAlert Color="KlyColor.Warning" Variant="KlyVariant.Soft" StatusIcon="true" Live="KlyAlertLive.Polite" Title="Quota warning"
Description="Your plan is almost full." Details="85% of the monthly volume is used. The next 15% costs 0.002 EUR per call."
ActionItems="@(new[] { new KlyActionItem("Upgrade") { Href = "#", Variant = ButtonVariant.Solid, Color = KlyColor.Warning } })" />
</div>API
KlyAlert
Inline message with an optional icon, title, description, actions and close button, for feedback that stays in the page flow.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
ActionItems |
IReadOnlyList |
Buttons or links under the description, from data ( KlyActionItem ). They are shown after Actions . | |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Close |
bool |
false |
Shows a close button that removes the alert. |
Color |
KlyColor |
"primary" |
Semantic color of the alert: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else the default of the component. Values: primary, secondary, success, info, warning, error, neutral. |
DefaultOpen |
bool |
false |
Whether Details starts open. It is read once, when the component first receives its parameters. |
Description |
string |
Text of the alert. Use ChildContent for markup. | |
Details |
string |
Collapsible text under the description, opened with a Show details toggle. The toggle is disabled until the page is interactive. | |
Live |
KlyAlertLive |
KlyAlertLive. |
Makes the alert a live region that assistive technology announces when it appears: Polite ( role="status" ) or Assertive ( role="alert" ). None (the default) adds no role. Use it for an alert that is inserted after the page loaded, not for one that is there from the start. Values: None, Polite, Assertive. |
StatusIcon |
bool |
false |
Shows the icon of the color (info, success, warning or error, from Icons ) when no Icon is given. |
Title |
string |
Title of the alert, shown above its description. | |
Ui |
AlertUi |
Per-instance class overrides of the slots of the alert, see AlertUi . They are merged after the theme and the Class parameter wins on the root slot. | |
Variant |
KlyVariant |
KlyVariant. |
Look of the alert: Solid , Outline , Soft or Subtle . Values: Solid, Outline, Soft, Subtle. |
Events
| Name | Type | Description |
|---|---|---|
OnClose |
EventCallback |
Raised when the user closes the alert with its close button. |
Slots
| Name | Type | Description |
|---|---|---|
Actions |
RenderFragment |
Buttons or links under the description of the alert. |
Icon |
RenderFragment |
Icon of the alert, as markup such as a KlyIcon . |
ChildContent |
RenderFragment |
Rich description, instead of Description . |
Ui slots
Ui takes a AlertUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlyAlert , after the theme and the app configuration. |
Icon |
Classes merged into the icon slot of KlyAlert , after the theme and the app configuration. |
Wrapper |
Classes merged into the wrapper slot of KlyAlert , after the theme and the app configuration. |
Title |
Classes merged into the title slot of KlyAlert , after the theme and the app configuration. |
Description |
Classes merged into the description slot of KlyAlert , after the theme and the app configuration. |
Actions |
Classes merged into the actions slot of KlyAlert , after the theme and the app configuration. |
Close |
Classes merged into the close slot of KlyAlert , after the theme and the app configuration. |
Toggle |
Classes merged into the toggle slot of KlyAlert , after the theme and the app configuration. |
ToggleIcon |
Classes merged into the toggleIcon slot of KlyAlert , after the theme and the app configuration. |
DetailsPanel |
Classes merged into the detailsPanel slot of KlyAlert , after the theme and the app configuration. |