Alert

Alerts are a powerful way to show your users important messages.

<x-alert description="I have an important message for you" />

#Variants

Use the color attribute to better convey what your message is about. The only values applicable to alerts are primary (FlyonUI only), info, success, warning and error.
While you are at it, the variant attribute can be used to create soft, outline or dash-styled alerts. This is useful if you want to e.g. apply a different alert style to errors shown when form fields are filled incorrectly or to toast messages.

<x-alert color="info" title="Information">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
</x-alert>
<x-alert color="info" title="Information" variant="soft">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
</x-alert>
<x-alert color="info" title="Information" variant="outline">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
</x-alert>
<x-alert color="info" title="Information" variant="dash">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
</x-alert>

Alternatively, the type attribute can be used to apply a color and a default icon at the same time. Here is a complete set of alerts.

<!-- Default type -->
<x-alert title="Default" description="Alert with no styling."/>
<x-alert title="Default" description="Soft alert."           variant="soft"/>
<x-alert title="Default" description="Outline-styled alert." variant="outline"/>
<x-alert title="Default" description="Dash-styled alert."    variant="dash"/>

<!-- Primary type -->
<x-alert type="primary" title="Primary (FlyonUI only)" description="Primary with no styling."/>
<x-alert type="primary" title="Primary (FlyonUI only)" description="Soft primary."          variant="soft"/>
<x-alert type="primary" title="Primary (FlyonUI only)" description="Outline-style primary." variant="outline"/>
<x-alert type="primary" title="Primary (FlyonUI only)" description="Dash-style primary."    variant="dash"/>

<!-- Info type -->
<x-alert type="info" title="Information" description="Info with no styling."/>
<x-alert type="info" title="Information" description="Soft info."          variant="soft"/>
<x-alert type="info" title="Information" description="Outline-style info." variant="outline"/>
<x-alert type="info" title="Information" description="Dash-style info."    variant="dash"/>

<!-- Success type -->
<x-alert type="success" title="Success" description="Success with no styling."/>
<x-alert type="success" title="Success" description="Soft success."           variant="soft"/>
<x-alert type="success" title="Success" description="Outline-styled success." variant="outline"/>
<x-alert type="success" title="Success" description="Dash-styled success."    variant="dash"/>

<!-- Warning type -->
<x-alert type="warning" title="Warning" description="Warning with no styling."/>
<x-alert type="warning" title="Warning" description="Soft warning."           variant="soft"/>
<x-alert type="warning" title="Warning" description="Outline-styled warning." variant="outline"/>
<x-alert type="warning" title="Warning" description="Dash-styled warning."    variant="dash"/>

<!-- Error type -->
<x-alert type="error" title="Error" description="Error with no styling."/>
<x-alert type="error" title="Error" description="Soft error."           variant="soft"/>
<x-alert type="error" title="Error" description="Outline-styled error." variant="outline"/>
<x-alert type="error" title="Error" description="Dash-styled error."    variant="dash"/>

#Icons

Icons, including the ones added by the type attribute, can be overriding by specifying the icon attribute of the alert.

<x-alert style="soft" type="info" icon="heroicon-o-bell-alert">
  An alert with a bell icon.
</x-alert>

It is also possible to fill the <x-slot:icon> element, instead of the attribute, to further customize the behavior. In the example below, the icon changes colors when hovering the alert.

<x-alert style="soft" type="info" class="group">
  <x-slot:icon>
	<x-icon name="heroicon-o-bell-alert" class="size-6 group-hover:text-secondary duration-250"/>
  </x-slot:icon>
  An alert with a bell icon.
</x-alert>

If you coded your alert with the type attribute (and its default icon), setting the icon to empty removes it.

<x-alert type="" style="soft">
  An alert without an icon.
</x-alert>

#Actions

The actions slot can be used to add buttons to the alert.
Buttons added there will be small by default but their size can be restored using one of the btn-<size> utility classes, as demonstrated below.

<x-alert type="info" title="Information">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
  <x-slot:actions class="flex gap-2">
    <x-button class="shadow-none">Ok</x-button>
    <x-button class="btn-outline">Cancel</x-button>
  </x-slot:actions>
</x-alert>

<x-alert type="info" title="Information">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
  <x-slot:actions class="flex gap-2 *:btn-md">
    <x-button class="shadow-none">Ok</x-button>
    <x-button class="btn-outline">Cancel</x-button>
  </x-slot:actions>
</x-alert>

<x-alert type="info" title="Information">
  Please read the <a href="#" class="link font-semibold">policy</a>. These can be configured in Settings.
  <x-slot:actions class="flex gap-2">
    <x-button class="btn-md shadow-none">Ok</x-button>
    <x-button class="btn-outline">Cancel</x-button>
  </x-slot:actions>
</x-alert>