Alerts inform the user about important information or changes to the system.

Basic Alerts

Alerts come in a variety of flavors and generally have an icon at the start to indicate the type of alert.

Preview
Code
= daisy_alert(icon: "archive-box", icon_html: { variant: :outline }, css: "w-100") do |alert|
  Standard alerts are gray-t!

= daisy_alert(icon: "information-circle", css: "alert-info w-100", icon_html: { variant: :outline }) do |alert|
  Here is some important information!

= daisy_alert(icon: "check-circle", css: "alert-success w-100", icon_html: { variant: :outline }) do |alert|
  Success! You did it!

= daisy_alert(icon: "exclamation-triangle", css: "alert-warning w-100", icon_html: { variant: :outline }) do |alert|
  Ooh, be careful here!

= daisy_alert(icon: "exclamation-circle", css: "alert-error w-100", icon_html: { variant: :outline }) do |alert|
  Uh oh, something went wrong!

Alerts Without Icons

If you don't want an icon, you can simply omit it.

Preview
Code
= daisy_alert(css: "alert-info w-100") do |alert|
  Here is some important information!

= daisy_alert(css: "alert-success w-100") do |alert|
  Success! You did it!

= daisy_alert(css: "alert-warning w-100") do |alert|
  Ooh, be careful here!

= daisy_alert(css: "alert-error w-100") do |alert|
  Uh oh, something went wrong!

Custom Icon Alerts

You can also use a custom icon (or any HTML) if you prefer.

Preview
Code
= daisy_alert do |alert|
  = hero_icon("star", css: "text-yellow-500")
  Custom icon alert!

= daisy_alert do |alert|
  %span ❤️
  %span Custom emoji alert!

= daisy_alert do |alert|
  = daisy_avatar(css: "size-10", src: image_path("avatars/lady-smiling-3.jpg"))
  %span Or even Daisy avatars / other elements!

Soft Alerts

Alerts can also be displayed in soft style.

Preview
Code
= daisy_alert(icon: "information-circle", css: "alert-info alert-soft") do
  Info alert.

= daisy_alert(icon: "check-circle", css: "alert-success alert-soft") do
  Success alert.

= daisy_alert(icon: "exclamation-triangle", css: "alert-warning alert-soft") do
  Warning alert.

= daisy_alert(icon: "exclamation-circle", css: "alert-error alert-soft") do
  Error alert.

Outline Alerts

Alerts can also be displayed in outline style.

Preview
Code
= daisy_alert(icon: "information-circle", css: "alert-info alert-outline") do
  Info alert.

= daisy_alert(icon: "check-circle", css: "alert-success alert-outline") do
  Success alert.

= daisy_alert(icon: "exclamation-triangle", css: "alert-warning alert-outline") do
  Warning alert.

= daisy_alert(icon: "exclamation-circle", css: "alert-error alert-outline") do
  Error alert.

Dash Alerts

Alerts can also be displayed in dash style.

Preview
Code
= daisy_alert(icon: "information-circle", css: "alert-info alert-dash") do
  Info alert.

= daisy_alert(icon: "check-circle", css: "alert-success alert-dash") do
  Success alert.

= daisy_alert(icon: "exclamation-triangle", css: "alert-warning alert-dash") do
  Warning alert.

= daisy_alert(icon: "exclamation-circle", css: "alert-error alert-dash") do
  Error alert.

Closable Alerts

Alerts can be manually closed by clicking the X button. Set closable: true to show the close button. Click the Reset button to show the alerts again after they are closed.

Preview
Code
= daisy_alert(icon: "information-circle", css: "alert-info w-100", closable: true, icon_html: { variant: :outline }) do
  This alert can be closed manually. It has multiple lines of text to show the
  close button positioning.

= daisy_alert(icon: "check-circle", css: "alert-success w-100", closable: true, icon_html: { variant: :outline }) do
  Success! Click the X to dismiss.
Reset

Auto-dismissing Alerts

Alerts can auto-dismiss after a specified timeout. Set autoclose: true and timeout in milliseconds. Click the Reset button to show the alerts again after they dismiss.

Preview
Code
= daisy_alert(icon: "check-circle", css: "alert-success w-100", autoclose: true, timeout: 3000, icon_html: { variant: :outline }) do
  This alert will auto-dismiss in 3 seconds.

= daisy_alert(icon: "information-circle", css: "alert-info w-100", autoclose: true, timeout: 5000, icon_html: { variant: :outline }) do
  This alert will auto-dismiss in 5 seconds.
Reset

Alerts can be converted to clickable links by providing an href parameter. Use target to control where the link opens.

Preview
Code
= daisy_alert(icon: "star", css: "alert-info w-100", href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", target: "_blank", icon_html: { variant: :outline }) do
  Click this alert for a surprise! (opens in new tab)

= daisy_alert(icon: "check-circle", css: "alert-success w-100", href: "/api-docs", target: "_blank", icon_html: { variant: :outline }) do
  Click to view documentation.

Stimulus Action Alerts

Alerts can trigger custom Stimulus actions by providing an action parameter.

Preview
Code
%div{ data: { controller: "alert-demo" } }
  = daisy_alert(icon: "sparkles", css: "alert-warning w-100 hover:cursor-pointer", action: "click->alert-demo#celebrate", html: { data: { alert_demo_target: "alert" } }, icon_html: { variant: :outline }) do
    Click to celebrate!

Custom Timeout Alerts

You can customize the timeout for each alert. Set autoclose: true with a custom timeout value. Click the Reset button to show the alerts again after they dismiss.

Preview
Code
= daisy_alert(icon: "check-circle", css: "alert-success w-100", autoclose: true, timeout: 2000, icon_html: { variant: :outline }) do
  Dismisses in 2 seconds.

= daisy_alert(icon: "information-circle", css: "alert-info w-100", timeout: 5000, icon_html: { variant: :outline }) do
  This alert will not auto-dismiss (autoclose is false by default).
Reset
Made with by Profoundry .
Copyright © 2023-2026 Profoundry LLC.
All rights reserved.