PHPackages                             mattlibera/livewire-flash - 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. mattlibera/livewire-flash

ActiveLibrary

mattlibera/livewire-flash
=========================

Flash notifications using Livewire

v1.0(3mo ago)12072.4k↓12.1%17[6 issues](https://github.com/mattlibera/livewire-flash/issues)[2 PRs](https://github.com/mattlibera/livewire-flash/pulls)2MITPHPPHP &gt;=8.0.0CI failing

Since Jul 17Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/mattlibera/livewire-flash)[ Packagist](https://packagist.org/packages/mattlibera/livewire-flash)[ RSS](/packages/mattlibera-livewire-flash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (20)Used By (2)

Warning

I'm considering this package EOL at this time. I do not have time to continue maintaining it, and its approach is pretty well out-of-date for most modern stacks. If someone wants to take over maintenance here, please let me know. Otherwise, this package will be officially deprecated.

Note

Version 1.0 requires PHP8 or above.

Livewire Flash
==============

[](#livewire-flash)

This package provides flash message capability using Laravel Livewire. It is based very literally on `laracasts/flash` but has been extended to add the ability to flash a message to a the flash container (a Livewire component) without reloading the page.

This package also retains much (though not all) of the same capability for "normal" flash messages, which are displayed on refresh by the same Livewire component.

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

[](#installation)

Install via composer:

```
composer require mattlibera/livewire-flash
```

Requirements
------------

[](#requirements)

Version 1.0 requires:

- Laravel &gt;=8.0
- Livewire ^2.12.7, or ^3.6.4

If you need legacy PHP or Livewire support please stay on v0.x

> For new applications, consider using the TALL preset for Laravel: \[\], or this package also works well with Laravel Jetstream: \[\]

Recommended add-ons
-------------------

[](#recommended-add-ons)

Out of the box, the default alert component uses:

- TailwindCSS (any version; see below for installation instructions)
- FontAwesome

However, it's fairly trivial to implement your own views / styles instead, by publishing the config and overriding defaults. See below for more on that.

### Tailwind setup (4.0+)

[](#tailwind-setup-40)

If using modern Tailwind CSS, you should add a couple of paths to your `app.css` as `@source` directives:

```
@source "../../vendor/mattlibera/livewire-flash/src/publish/livewire-flash.php";
@source "../../vendor/mattlibera/livewire-flash/src/views/livewire/*.blade.php";
```

Of course, if you publish the views/config, you'll reference your own copies instead.

### Tailwind setup (&gt; 4.0)

[](#tailwind-setup--40)

If you are using legacy Tailwind CSS, you should amend the `content` section of your `tailwind.config.js` to include the appropriate files from this package:

```
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./resources/**/*.blade.php",
    "./resources/**/*.js",
    "./resources/**/*.vue",
    "./vendor/mattlibera/livewire-flash/src/publish/livewire-flash.php",
    "./vendor/mattlibera/livewire-flash/src/views/livewire/*.blade.php",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
```

Of course, if you publish the views/config, you'll reference your own copies instead.

Usage
-----

[](#usage)

### Normal flash messages (on reload)

[](#normal-flash-messages-on-reload)

Call the `flash()` helper from your code somewhere, before you redirect.

```
public function store()
{
    flash('Success!');

    return redirect()->back();
}
```

### Livewire flash message (before reload)

[](#livewire-flash-message-before-reload)

From your Livewire component, flash your message using the normal syntax, but then call the `livewire()` helper method as the last method in the chain. You must pass in `$this` as the argument, as this package utilizes the `emit` helper that exists on all Livewire components. Example:

```
public function livewireAction()
{
    flash('Your request was successful!')->success()->livewire($this);
}
```

### Message types

[](#message-types)

Message types are defined in the `livewire-flash.php` config file, which can be published (see below) if desired. By default, there are four supported message types: `info` (default if nothing else is specified), `success`, `warning`, and `error`.

To set a message's type, either:

1. Pass it as the second argument to `flash()` - example: `flash('Your action succeeded', 'success')`, or
2. Chain it as a method name fluently after `flash()` - example: `flash('Your action succeeded')->success()`

Both of those will change the message's display (colors and icon) to the configured styles.

### Overlay Message

[](#overlay-message)

Overlay message is defined in the `livewire-flash.php` config file, which can be published (see below) if desired.

To set an overlay message, chain the method name `overlay()` after `flash()`. When using overlay leave the `flash()` parameter empty. Enter your message as the first parameter and title as second parameter for `overlay()`. This can be used with or without the `livewire($this)` suffix:

```
// renders on next page load
flash()->overlay('This is my message', 'The Title');
return redirect('somewhere');

// renders immediately via Livewire
flash()->overlay('This is my message', 'The Title')->livewire($this);

```

Note that the out-of-the-box overlay component does support HTML code for the body and title, using the Blade unescaped `{!! !!}` tags.

### Customization

[](#customization)

To change the styles used by each message type, OR to add your own types, first publish the config file:

```
php artisan vendor:publish --provider="MattLibera\LivewireFlash\LivewireFlashServiceProvider"
```

Then, in the `styles` key you can change whatever you want:

```
'styles' => [
    'info' => [
        'bg-color'     => 'bg-blue-100', // could change to bg-purple-100, or something.
        'border-color' => 'border-blue-400',
        'icon-color'   => 'text-blue-400',
        'text-color'   => 'text-blue-800',
        'icon'         => 'fas fa-info-circle', // could change to another FontAwesome icon
    ],
```

Or you can add your own:

```
'notice' => [
    'bg-color'     => 'bg-orange-100',
    'border-color' => 'border-orange-400',
    'icon-color'   => 'text-orange-400',
    'text-color'   => 'text-orange-800',
    'icon'         => 'fas fa-flag',
],
```

Whatever the case, just ensure that you call the alert by its config key: `flash('An important message')->notice()`

To customize overlay styles, see the `overlay` key of the config file.

Templates
---------

[](#templates)

Out of the box, the Livewire Flash Container component is registered for you. All you have to do is include it in your template:

```

```

There are also some sample alert components (styled using TailwindCSS) included with this package. However, if you do not wish to use those...

### Customization

[](#customization-1)

You can change the views that the Livewire components use for rendering, and the styles applied to each message type.

> If you are not using TailwindCSS and/or FontAwesome, you should definitely do this to call your own alert component/partial to fit whatever your stack is using.

First, publish the config file:

```
php artisan vendor:publish --provider="MattLibera\LivewireFlash\LivewireFlashServiceProvider"
```

Then, edit the `views` area:

```
'views' => [
    'container' => 'livewire-flash::livewire.flash-container',
    'message'   => 'partials.my-bootstrap-flash',
],
```

You can access the public message properties on `MattLibera\LivewireFlash\Message`, as well as `$styles` (which is injected via the Livewire component) in your template.

Dismissible Messages
--------------------

[](#dismissible-messages)

By default, each message will be set to be dismissible (that is, have an X icon at the right that will close the alert). If you wish to prevent this, you can chain `->notDismissable()` (or `->dismissable(false)`) to your flash directive.

You can add your own magic via AlpineJS or whatever else if you want to fade messages out automatically - right now each message is a Livewire component and uses Livewire logic to hide it when it is dismissed.

*Note that the overlay does not support this directive.*

Multiple Flash Messages
-----------------------

[](#multiple-flash-messages)

Multiple flash messages can be sent to the session:

```
// anywhere
flash('Message 1');
flash('Message 2')->warning();

return redirect('somewhere');
```

OR

```
// livewire component
flash('Message 1')->livewire($this);
flash('Message 2')->warning()->livewire($this);
```

However, at the moment, because of the way Livewire handles the session, you *cannot* mix-and-match... that is, you cannot do:

```
// livewire component
flash('Message 1'); // this one will get lost.
flash('Message 2')->livewire($this); // this one will show on current page via Livewire
```

Contributing
============

[](#contributing)

I am open to contributions to this package, and will do the best I can to maintain it over time. Pull requests are welcome, and in fact encouraged. Right now there are no specific guidelines for a PR.

Road Map
========

[](#road-map)

Some considerations for future versions:

- Fluent options for setting an icon or colors on the fly
- Auto-dismissing option for flash messages

Credits and License
===================

[](#credits-and-license)

Credit for the original package goes to Jeffrey Way and Laracasts. Additional thanks:

- Caleb Porzio and his Livewire contributors for the awesome framework
- Adam Wathan and the Tailwind crew
- Taylor Otwell and co. for Laravel

This is an MIT-licensed package. Please read license.md for the details.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity46

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 93.6% of commits — single point of failure

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 ~143 days

Recently: every ~338 days

Total

15

Last Release

119d ago

Major Versions

v0.9 → v1.02026-01-19

PHP version history (2 changes)v0.1PHP &gt;=7.3.0

v1.0PHP &gt;=8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ce471e2de121a224b350c231f89f12917e46345b1ce13a0deadfd16781d0f23?d=identicon)[mattlibera](/maintainers/mattlibera)

---

Top Contributors

[![mattlibera](https://avatars.githubusercontent.com/u/6657359?v=4)](https://github.com/mattlibera "mattlibera (44 commits)")[![mul14](https://avatars.githubusercontent.com/u/113989?v=4)](https://github.com/mul14 "mul14 (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mattlibera-livewire-flash/health.svg)

```
[![Health](https://phpackages.com/badges/mattlibera-livewire-flash/health.svg)](https://phpackages.com/packages/mattlibera-livewire-flash)
```

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[livewire-filemanager/filemanager

A simple, friendly and practical Livewire filemanager for your applications

3587.6k1](/packages/livewire-filemanager-filemanager)[calebdw/larastan-livewire

A Larastan / PHPStan extension for Livewire.

43482.4k3](/packages/calebdw-larastan-livewire)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

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