Skip to content
GitHub11 stars

Displays a callout for user attention.

<div class="grid w-full max-w-md items-start gap-4">
    <Alert>
        <Icon Data="LucideIcons.CheckCircle2" />

Installation

dnx Blazix.Cli add alert

Usage

<Alert>
    <Icon Data="LucideIcons.Info" />
    <AlertTitle>Heads up!</AlertTitle>
    <AlertDescription>You can add components and dependencies to your app using the cli.</AlertDescription>
    <AlertAction><Button Variant="ButtonVariant.Outline">Enable</Button></AlertAction>
</Alert>

Composition

Use the following composition to build an Alert:

Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction

Basic

A basic alert with an icon, title and description.

<Alert Class="max-w-md">
    <Icon Data="LucideIcons.CheckCircle2" />
    <AlertTitle>Account updated successfully</AlertTitle>
    <AlertDescription>Your profile information has been saved. Changes will be reflected immediately.</AlertDescription>
</Alert>

Destructive

Use variant="destructive" to create a destructive alert.

<Alert Variant="AlertVariant.Destructive" Class="max-w-md">
    <Icon Data="LucideIcons.AlertCircle" />
    <AlertTitle>Payment failed</AlertTitle>
    <AlertDescription>Your payment could not be processed. Please check your payment method and try again.</AlertDescription>
</Alert>

Action

Use AlertAction to add a button or other action element to the alert.

<Alert Class="max-w-md">
    <AlertTitle>Dark mode is now available</AlertTitle>
    <AlertDescription>Enable it under your profile settings to get started.</AlertDescription>
    <AlertAction><Button Size="ButtonSize.Xs" Variant="ButtonVariant.Default">Enable</Button></AlertAction>
</Alert>

Custom Colors

You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert component.

<Alert Class="max-w-md border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-50">
    <Icon Data="LucideIcons.AlertTriangle" />
    <AlertTitle>Your subscription will expire in 3 days.</AlertTitle>
    <AlertDescription>
        Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.
    </AlertDescription>
</Alert>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

<div class="grid w-full max-w-md items-start gap-4">
    <Alert>
        <Icon Data="LucideIcons.CheckCircle2" />

API Reference

Alert

ParameterTypeDefault
Variant AlertVariant AlertVariant.Default
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AlertAction

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AlertDescription

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AlertTitle

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.