- Blade Components
- Docs
- Components
- Alert
Alert
Display text that requires attention or provides additional information.
Usage
<x-alert>This alert details some information.</x-alert>
Component API
Attribute | Default | Description |
---|---|---|
title |
null |
string || null Optional title for added clarity. |
style |
default |
string Possible values default , success , info , warning or danger . |
icon |
null |
string Optional component alias of the icon. |
Title
For added clarity a title can be added to the alert by supplying the title=""
attribute.
Style
Control the alert style by supplying the style=""
attribute.
Icon
You can control the icon per alert instance by supplying the icon=""
attribute. Any blade-ui-kit/blade-icons compatible icon set can be used.
Customizing the default icons
The alert component uses the blade-ui-kit/blade-heroicons icon set by default.
Style | Default Icon |
---|---|
default |
heroicon-o-information-circle |
success |
heroicon-o-check-circle |
info |
heroicon-o-information-circle |
warning |
heroicon-o-exclamation-circle |
danger |
heroicon-o-x-circle |
You can customize the default icons globally by calling either the setDefaultIcons()
or setDefaultIconForStyle()
method from a service provider's boot()
method, or middleware.
The setDefaultIcons()
method takes an array of icon definitions.
<?php
use DistortedFusion\BladeComponents\Components\Alert\Index as Alert;
Alert::setDefaultIcons([
'default' => 'heroicon-o-information-circle',
'success' => 'heroicon-o-check-circle',
'info' => 'heroicon-o-information-circle',
'warning' => 'heroicon-o-exclamation-circle',
'danger' => 'heroicon-o-x-circle',
]);
The setDefaultIconForStyle()
method sets the icon for a specific style.
<?php
use DistortedFusion\BladeComponents\Components\Alert\Index as Alert;
Alert::setDefaultIconForStyle(
style: 'default',
icon: 'heroicon-o-information-circle'
);