Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight colors.
A simple primary alert - check it out!
A simple secondary alert - check it out!
A simple success alert - check it out!
A simple danger alert - check it out!
A simple warning alert - check it out!
A simple info alert - check it out!
A simple light alert - check it out!
A simple dark alert - check it out!
<Alert Color="AlertColor.Primary"> A simple primary alert - check it out! </Alert>
<Alert Color="AlertColor.Secondary"> A simple secondary alert - check it out! </Alert>
<Alert Color="AlertColor.Success"> A simple success alert - check it out! </Alert>
<Alert Color="AlertColor.Danger"> A simple danger alert - check it out! </Alert>
<Alert Color="AlertColor.Warning"> A simple warning alert - check it out! </Alert>
<Alert Color="AlertColor.Info"> A simple info alert - check it out! </Alert>
<Alert Color="AlertColor.Light"> A simple light alert - check it out! </Alert>
<Alert Color="AlertColor.Dark"> A simple dark alert - check it out! </Alert>
Use the alert-link css class to quickly provide matching colored links within any alert.
A simple primary alert with an example link. Give it a click if you like.
A simple secondary alert with an example link. Give it a click if you like.
A simple success alert with an example link. Give it a click if you like.
A simple danger alert with an example link. Give it a click if you like.
A simple warning alert with an example link. Give it a click if you like.
A simple info alert with an example link. Give it a click if you like.
A simple light alert with an example link. Give it a click if you like.
A simple dark alert with an example link. Give it a click if you like.
<Alert Color="AlertColor.Primary">
A simple primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Secondary">
A simple secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Success">
A simple success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Danger">
A simple danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Warning">
A simple warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Info">
A simple info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Light">
A simple light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
<Alert Color="AlertColor.Dark">
A simple dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</Alert>
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
Well done!
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
Razor
<Alert Color="AlertColor.Success">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</Alert>
1. Using the Dismissable="true", it’s possible to dismiss any alert inline.
Holy guacamole! You should check in on some of those fields below.
<Alert Color="AlertColor.Warning" Dismissable="true"> <strong>Holy guacamole!</strong> You should check in on some of those fields below. </Alert>
2. Manually we can close an alert with button click.
Holy guacamole! You should check in on some of those fields below.
<Alert @ref="warningAlert" Color="AlertColor.Warning">
<strong>Holy guacamole!</strong> You should check in on some of those fields below. <Button Color="ButtonColor.Primary" @onclick="CloseAlert">Close</Button>
</Alert>
@code {
Alert warningAlert = default!;
private async Task CloseAlert() => await warningAlert.CloseAsync();
}
WARNING
When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document.
For this reason, we recommend subscribing to the OnClosed callback event and programmatically sets focus to the most appropriate location on the page.