DAlert
Colors
Default alert
Info alert
Success alert
Warning alert
Error alert
<DAlert>Default alert</DAlert>
<DAlert Color="DaisyColor.Info">Info alert</DAlert>
<DAlert Color="DaisyColor.Success">Success alert</DAlert>
<DAlert Color="DaisyColor.Warning">Warning alert</DAlert>
<DAlert Color="DaisyColor.Error">Error alert</DAlert>Variants
Outline
Dash
Soft
<DAlert Color="DaisyColor.Info" Variant="DaisyVariant.Outline">Outline</DAlert>
<DAlert Color="DaisyColor.Info" Variant="DaisyVariant.Dash">Dash</DAlert>
<DAlert Color="DaisyColor.Info" Variant="DaisyVariant.Soft">Soft</DAlert>DAlert is an inline component — it sits in the page flow. For transient
corner notifications, combine it with DToast (a fixed-position
toast container). These auto-dismiss after 3.5 s and have a close button.
As toast notifications
<DButton Color="DaisyColor.Success" OnClick="@(() => ShowToast("Changes saved", DaisyColor.Success))">Success toast</DButton>
<DButton Color="DaisyColor.Info" OnClick="@(() => ShowToast("New version available", DaisyColor.Info))">Info toast</DButton>
<DButton Color="DaisyColor.Error" OnClick="@(() => ShowToast("Something went wrong", DaisyColor.Error))">Error toast</DButton>
<DToast Position="DaisyToastPosition.BottomEnd">
@foreach (var toast in _toasts)
{
<DAlert Color="@toast.Color" Class="shadow-lg max-w-xs">
<ChildContent>
<div class="flex items-center justify-between gap-4">
<span>@toast.Message</span>
<button type="button" class="btn btn-ghost btn-xs" @onclick="() => Dismiss(toast)">✕</button>
</div>
</ChildContent>
</DAlert>
}
</DToast>
@code {
private sealed record ToastItem(string Message, DaisyColor Color);
private readonly List<ToastItem> _toasts = [];
private void ShowToast(string message, DaisyColor color)
{
var item = new ToastItem(message, color);
_toasts.Add(item);
// Fire-and-forget: awaiting the timer inside the click handler would make the
// renderer wait for the handler task before showing the toast.
_ = AutoDismissAsync(item);
}
private async Task AutoDismissAsync(ToastItem item)
{
await Task.Delay(3500);
// Return to the renderer's synchronization context before touching state:
// under Blazor Server the continuation may otherwise run off-dispatcher.
await InvokeAsync(() =>
{
_toasts.Remove(item);
StateHasChanged();
});
}
private void Dismiss(ToastItem item)
{
_toasts.Remove(item);
}
}With icon
Saved!
Your changes have been saved successfully.
Heads up — scheduled maintenance tonight.
Your trial expires in 3 days.
Upload failed. Please retry.
CDN icon (lucide via Iconify) — still inherits the text color.
<DAlert Color="DaisyColor.Success" Icon="@DaisyIcons.Success">
<strong class="block font-bold">Saved!</strong>
Your changes have been saved successfully.
</DAlert>
<DAlert Color="DaisyColor.Info" Icon="@DaisyIcons.Info">Heads up — scheduled maintenance tonight.</DAlert>
<DAlert Color="DaisyColor.Warning" Icon="@DaisyIcons.Warning">Your trial expires in 3 days.</DAlert>
<DAlert Color="DaisyColor.Error" Icon="@DaisyIcons.Error">Upload failed. Please retry.</DAlert>
<DAlert Icon="@DaisyIcon.FromUrl("rocket", "https://api.iconify.design/lucide/rocket.svg")">
CDN icon (lucide via Iconify) — still inherits the text color.
</DAlert>API
DAlert
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Color | DaisyColor | Default | — | Contextual color (e.g. alert-info , alert-success ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. alert-outline , alert-soft ); Default emits no class. DefaultOutlineDashSoftLink |
| Icon | DaisyIcon | — | — | Optional leading icon (e.g. DaisyIcons.Warning or a CDN icon via DaisyIcon.FromUrl ). |
| IconSize | DaisySize | Large | — | Icon size for Icon . ExtraSmallSmallMediumLargeExtraLarge |
| ChildContent | RenderFragment | — | — | The alert's message content. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DToast
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| ChildContent | RenderFragment | — | — | Notifications to display stacked inside the toast container (typically DAlert). |
| Position | DaisyToastPosition | BottomEnd | — | Where on the screen the container is anchored. Defaults to bottom-end. TopStartTopCenterTopEndMiddleStartMiddleCenterMiddleEndBottomStartBottomCenterBottomEnd |
| Reverse | bool | False | — | Reverses the stacking order of the notifications (daisyUI toast-reverse). |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DButton
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Type | string | button | — | The native type attribute: button , submit or reset . |
| Color | DaisyColor | Default | — | Contextual color (e.g. btn-primary , btn-ghost ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. btn-outline , btn-soft ); Default emits no class. DefaultOutlineDashSoftLink |
| Size | DaisySize | Medium | — | Size (e.g. btn-xs , btn-lg ); Medium emits no class. ExtraSmallSmallMediumLargeExtraLarge |
| Disabled | bool | False | — | Disables the button (native disabled ). |
| IconStart | DaisyIcon | — | — | Icon rendered before the button content (daisy's btn gap handles spacing). |
| IconEnd | DaisyIcon | — | — | Icon rendered after the button content. |
| IconSize | DaisySize? | — | — | Icon size; defaults to the button Size when null . ExtraSmallSmallMediumLargeExtraLarge |
| Shape | DaisyButtonShape | Default | — | btn-square / btn-circle — use with an icon and no text for icon-only buttons. DefaultSquareCircle |
| Wide | bool | False | — | btn-wide : widens the button to width:100% of its container, capped at 16rem . When both Wide and Block are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity) and the button fills its container, still capped at 16rem by btn-wide 's max-width . |
| Block | bool | False | — | btn-block : the button fills the full width of its container ( width:100% ). When both Block and Wide are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity). |
| ChildContent | RenderFragment | — | — | The button's inner text and content. |
| OnClick | EventCallback<MouseEventArgs> | — | — | Invoked when the button is clicked. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |