PHPackages                             dlogon/tailwind-alerts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dlogon/tailwind-alerts

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dlogon/tailwind-alerts
======================

create tailwind alerts from static

V0.2.1(1y ago)0309[1 PRs](https://github.com/Dlogon/tailwind-alerts/pulls)2MITBladePHP ^8.1CI failing

Since Oct 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Dlogon/tailwind-alerts)[ Packagist](https://packagist.org/packages/dlogon/tailwind-alerts)[ Docs](https://github.com/Dlogon/tailwind-alerts)[ RSS](/packages/dlogon-tailwind-alerts/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (5)Used By (2)

Tailwind-alerts
===============

[](#tailwind-alerts)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2913119dcc8b7a2bfce05a7de35df2a3fb128155b06a5d377249f8da552fd159/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646c6f676f6e2f7461696c77696e642d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dlogon/tailwind-alerts)[![GitHub Tests Action Status](https://camo.githubusercontent.com/087c8cb5de64d7559e9fdb362f17b26a8e0bf87905706cf3ddf64b8b8f7da903/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f646c6f676f6e2f7461696c77696e642d616c657274732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/dlogon/tailwind-alerts/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/bf7aa65328ff625ce0894d1c40a2d65a21f7d2ce7599121e5939ec4f6184eddc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f646c6f676f6e2f7461696c77696e642d616c657274732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/dlogon/tailwind-alerts/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/670f75d48df24ea98dcd218c44ab10294c8b63cfab30552f832c9b19f655ce0a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646c6f676f6e2f7461696c77696e642d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dlogon/tailwind-alerts)

Add tailwind alerts to your page with a single facade call

```
TailwindAlerts::addSessionMessage("This beautifull asset as been saved", TailwindAlerts::SUCCESS);
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dlogon/tailwind-alerts
```

You need [tailwind](https://tailwindcss.com/) V2 or V3 and you need to check if your project has the default\_alert\_colors in your tailwind config file, if not, you can export the config file to change the default colors, or simply you can pass the background color you want in the level parameter, or you can add the config file inside the content node on module exports in your tailwind config file

```
const defaultTheme = require('tailwindcss/defaultTheme');

/** @type {import('tailwindcss').Config} */
module.exports = {
    content: [
        './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
        './storage/framework/views/*.php',
        './resources/views/**/*.blade.php',
        './vendor/dlogon/tailwind-alerts/config/tailwind-alerts.php',
    ],

    theme: {
        extend: {
            fontFamily: {
                sans: ['Nunito', ...defaultTheme.fontFamily.sans],
            },
        },

    },

    plugins: [require('@tailwindcss/forms')],
};
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Dlogon\TailwindAlerts\TailwindAlertsServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
"default_alert_colors" =>
    [
        "SUCCESS" => "bg-green-500",
        "ERROR" => "bg-red-500",
        "WARNING" => "bg-yellow-500",
        "INFO" => "bg-blue-500"
    ],

    "session_name" => env("TAILWIND_ALERTS", "tailwind_alerts"),

    "new_colors" => []
```

Usage
-----

[](#usage)

add this [Blade template](https://laravel.com/docs/9.x/blade)
inside your viewport html wrapper

```
@tailwind_alerts
```

or you can choose the component style

```

```

Then, you can use the facade in any part of your code to add a toast message

```
namespace App\Http\Controllers;

use App\Models\MyModel;
use Dlogon\TailwindAlerts\Facades\TailwindAlerts;
class MyController extends Controller
{
    ...
    public function store(Request $request)
    {
        TailwindAlerts::addSessionMessage("This beautifull asset as been saved", TailwindAlerts::SUCCESS);
        Mymodel::create($request->all())
        return redirect()->route("My.index");
    }
    ...
});
```

Result [![example](example.png?raw=true "example")](example.png?raw=true)

the default position and type of the alert is bottom toast, you can use 4 types of alerts, calling the addSessionMessage whit the correct parameters, or calling the helper functions

Then, you can use the facade in any part of your code to add a toast message

```
use Dlogon\TailwindAlerts\Facades\TailwindAlerts;

TailwindAlerts::addSessionMessage("Bottom toast", "bg-red-300", TailwindAlerts::BOTTOM_TOAST_CONTAINER, TailwindAlerts::TOAST_TEMPLATE );
TailwindAlerts::addBottomToastMessage("Another bottom toast", TailwindAlerts::ERROR);

TailwindAlerts::addTopToastMessage("Top toast", TailwindAlerts::WARNING);
TailwindAlerts::addHeaderMessage("Header line", TailwindAlerts::ERROR);
TailwindAlerts::addFooterMessage("Footer line", TailwindAlerts::DEFAULT_ALERT);
```

Result

[![diferent alerts](https://user-images.githubusercontent.com/26014056/197311450-cdef3660-626b-43dc-9f82-18c722e08c32.png)](https://user-images.githubusercontent.com/26014056/197311450-cdef3660-626b-43dc-9f82-18c722e08c32.png)

If your response is not a redirect response, then you should set the `$IsResponseRedirect` static variable to false using the method `setResponseRedirect(bool $value)` if you use the helper functions, or you can set the last parameter in `addSessionMessage()` to `false`

```
use Dlogon\TailwindAlerts\Facades\TailwindAlerts;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    TailwindAlerts::setResponseRedirect(false);
    TailwindAlerts::addSessionMessage("Welcome", TailwindAlerts::SUCCESS);
    return view('welcome');
});
```

Where you use the component, you are able to use a javascript function to show alerts

```
AlertToast.showToast("An error", AlertToast.ERROR, AlertToast.TOP_TOAST_CONTAINER, AlertToast.TOAST_TEMPLATE)
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Diego](https://github.com/Dlogon)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~435 days

Total

3

Last Release

434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cbabf513fe11ca7f29c1ab555af3d1f978c9d1996357edc5b4ccdbc0ce195959?d=identicon)[dlogon](/maintainers/dlogon)

---

Top Contributors

[![Dlogon](https://avatars.githubusercontent.com/u/26014056?v=4)](https://github.com/Dlogon "Dlogon (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laraveltoasttailwind-alerts

### Embed Badge

![Health badge](/badges/dlogon-tailwind-alerts/health.svg)

```
[![Health](https://phpackages.com/badges/dlogon-tailwind-alerts/health.svg)](https://phpackages.com/packages/dlogon-tailwind-alerts)
```

###  Alternatives

[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k2.9M21](/packages/realrashid-sweet-alert)[masmerise/livewire-toaster

Beautiful toast notifications for Laravel / Livewire.

505550.3k6](/packages/masmerise-livewire-toaster)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
