PHPackages                             kirschbaum-development/livewire-filters - 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. [Search &amp; Filtering](/categories/search)
4. /
5. kirschbaum-development/livewire-filters

ActiveLibrary[Search &amp; Filtering](/categories/search)

kirschbaum-development/livewire-filters
=======================================

Livewire Filters is a series of Livewire components that provide you with the tools to do live filtering of your data from your own Livewire components.

0.5(3y ago)164.1k[2 PRs](https://github.com/kirschbaum-development/livewire-filters/pulls)MITPHPPHP &gt;=8.0

Since Feb 25Pushed 2y ago14 watchersCompare

[ Source](https://github.com/kirschbaum-development/livewire-filters)[ Packagist](https://packagist.org/packages/kirschbaum-development/livewire-filters)[ Docs](https://github.com/kirschbaum-development/livewire-filters)[ GitHub Sponsors](https://github.com/kirschbaum-development)[ RSS](/packages/kirschbaum-development-livewire-filters/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (6)Dependencies (10)Versions (11)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a7cc3bc4dad99636418f6938a86b2f2f26fe1c20244d4252dae1dc409a223c8e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69727363686261756d2d646576656c6f706d656e742f6c697665776972652d66696c74657273)](https://packagist.org/packages/kirschbaum-development/livewire-filters)[![Total Downloads](https://camo.githubusercontent.com/da8749a3ed02e8489259c0894faf75c5133cc58ab4f88b9553817df24eb38a4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69727363686261756d2d646576656c6f706d656e742f6c697665776972652d66696c74657273)](https://packagist.org/packages/kirschbaum-development/livewire-filters)[![Actions Status](https://github.com/kirschbaum-development/livewire-filters/workflows/run-tests/badge.svg)](https://github.com/kirschbaum-development/livewire-filters/actions)

Livewire Filters is a series of Livewire components that provide you with the tools to do live filtering of your data from your own Livewire components.

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

[](#requirements)

This package requires Laravel 9.0+ and Livewire 2.10+.

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

[](#installation)

To get started, require the package via Composer:

```
composer require kirschbaum-development/livewire-filters
```

### Publishing views

[](#publishing-views)

The included filters are made with [Tailwind CSS](https://tailwindcss.com) and the [Tailwind CSS Forms plugin](https://github.com/tailwindlabs/tailwindcss-forms). We recommend publishing the views and changing the markup to match whatever styling or CSS framework your project uses.

```
php artisan vendor:publish --tag=livewire-filters-views
```

### Publishing config

[](#publishing-config)

Publishing the config file is only necessary to enable query string usage.

```
php artisan vendor:publish --tag=livewire-filters-config
```

Usage
-----

[](#usage)

### Define your filters

[](#define-your-filters)

You can use filters in your Livewire component by including the `HasFilters` trait provided by the package.

With the trait included, define a `filters` method that returns an array of `Filter` objects you want to use in your component. The included `Filter` class has a series of fluent methods for building up the specifics of each of your filters.

```
use HasFilters;

public function filters(): array
{
    return [
        Filter::make('title'),
        Filter::make('type')->options(['text', 'link', 'audio', 'video'])->default(['audio']),
        Filter::make('status')->options(['published', 'draft'])->default('published'),
    ];
}
```

### Use your filters

[](#use-your-filters)

With your component setup, you can include filters in the view file of your Livewire component. In order to setup the filter, simply use one of the filter components and pass the specific filter by its key. The component will take care of setting itself up.

```

```

There is more information below about the included filters in the package.

### Determining filtered status/count

[](#determining-filtered-statuscount)

The `HasFilters` trait includes two computed properties you can use to determine if there are active filters and how many of your filters are currently active. You can access these directly in your Livewire component by using `$this->isFiltered` or `$this->activeFilterCount`. You can also pass one or both of these properties to your Livewire component through the `render` method if you so choose.

These computed properties are handy if you want to change the color of a button, show/hide a specific section of your UI, show a badge of active filters, or simply show a visual indicator that there are active filters being applied.

### Getting filtered values

[](#getting-filtered-values)

Because the `$filters` array contains `Filter` objects, you will need to either access the `value` property, use the `value()` method, or use the included `getFilterValue($key)` helper method.

```
// Helper included in the HasFilters trait
$this->getFilteredValue('type');

// Using the accessor
$this->filters['type']->value();

// Using the property directly
$this->filters['type']->value;
```

### Example parent component

[](#example-parent-component)

```
use App\Models\Post;
use Kirschbaum\LivewireFilters\Filter;
use Kirschbaum\LivewireFilters\HasFilters;
use Livewire\Component;

class PostsList extends Component
{
    use HasFilters;

    public function filters(): array
    {
        return [
            Filter::make('type')->options(['text', 'link', 'audio', 'video'])->default(['text', 'link']),
        ];
    }

    public function getPostsProperty()
    {
        return Post::query()
            ->when($this->getFilterValue('type'), fn ($query, $values) => $query->whereIn('type', $values))
            ->paginate();
    }

    public function render()
    {
        return view('livewire.posts-list', [
            'filterCount' => $this->filterCount,
            'isFiltered' => $this->isFiltered,
            'posts' => $this->posts,
        ]);
    }
}
```

Included filters
----------------

[](#included-filters)

The package includes 4 basic filters that can be used in your Livewire components.

### Checkbox filter

[](#checkbox-filter)

The checkbox filter allows you to select any number of options. Every time a change is made, the filter will emit an event with an array of the currently checked values.

```

```

SettingTypeExamplekey`string``'type'`options`array``['a', 'b', 'c']`default`array``['a', 'b']`value`array``['b', 'c']`### Radio button filter

[](#radio-button-filter)

The radio button filter allows you to select a single option from the list of options. Every time a change is made, the filter will emit an event with the currently checked value.

```

```

SettingTypeExamplekey`string``'type'`options`array``['a', 'b', 'c']`default`string``'a'`value`string``'b'`### Select menu filter

[](#select-menu-filter)

Similar to the radio button filter, the select menu filter allows you to select a single option from the list of options from a select menu. Every time a change is made, the filter will emit an event with the currently selected value.

```

```

SettingTypeExamplekey`string``'type'`options`array``['a', 'b', 'c']`default`string``'a'`value`string``'b'`### Text box filter

[](#text-box-filter)

The text box filter allows you to type freeform text that you can use for filtering. Every time a change is made, the filter will emit an event with the value of the text field.

```

```

SettingTypeExamplekey`string``'name'`default`string``'John'`value`string``'Jane'`The `Filter` class
------------------

[](#the-filter-class)

The `Filter` class provides a fluent interface for defining filters in your Livewire component as well as retrieving information about the filter.

### `make($key)`

[](#makekey)

The first method you must call is the `make` method and pass it a unique key. After this method has been called, you can call any of the other methods in whatever order you want.

### `options($values)`

[](#optionsvalues)

If you're using a filter that requires options, you can pass an array of those values into the `options` method. Calling the `options` method without any arguments will return the defined options for the filter.

### `value($values)`

[](#valuevalues)

If you would like to set the value of a filter, you can pass the value or an array of values into the `value` method. Calling the `value` method without any arguments will return the current value of the filter.

### `default($values)`

[](#defaultvalues)

When defining a filter, you should use the `default` method to set the initial value of the filter. This will store the initial value on the object as well to help with determining the status of active filters as well as resetting the filter to its original state. Calling the `default` method without any arguments will return the initial value that you specified when you defined the filter.

### `meta(array $values)`

[](#metaarray-values)

If you would like to set additional information on the filter to be used in the view file, you can pass an array of values into the `meta` method. Calling the `meta` method without any arguments will return the current array of meta information.

Events
------

[](#events)

### `livewire-filters-reset`

[](#livewire-filters-reset)

### `livewire-filters-updated`

[](#livewire-filters-updated)

When a filter is updated, it will emit this event with 2 arguments: `key` and `payload`. The key should be used in identifying which filter should be updated. The `payload` is the new value of the filter.

This event is automatically handled by the `HasFilters` trait. If you would like to customize how the updates are handled, you can listen for this event and use your own method or override the `handleUpdateEvent` method.

Making your own filters
-----------------------

[](#making-your-own-filters)

In addition to the included filters, you can also make additional filters to suit your needs.

```
use Kirschbaum\LivewireFilters\FilterComponent;

class DateFilter extends FilterComponent
{
    public function render()
    {
        return view('livewire.filters.date-filter');
    }
}
```

```

    @if ($value !== $initialValue)

                Reset

    @endif

```

Changelog
---------

[](#changelog)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  or  instead of using the issue tracker.

Credits
-------

[](#credits)

- [David VanScott](https://github.com/davidvanscott)

Sponsorship
-----------

[](#sponsorship)

Development of this package is sponsored by Kirschbaum, a developer driven company focused on problem solving, team building, and community. Learn more [about us](https://kirschbaumdevelopment.com) or [join us](https://careers.kirschbaumdevelopment.com)!

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.3% 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 ~79 days

Recently: every ~99 days

Total

6

Last Release

1133d ago

PHP version history (2 changes)0.1PHP ^8.0

0.5PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f56743d64d77958321d43b2df49e9696d19c9dd99995730c5c38ccae50408fa?d=identicon)[Kirschbaum](/maintainers/Kirschbaum)

![](https://www.gravatar.com/avatar/6a683769667e8fe4ec012a7aaab07134bf722f4a96f625eb3e93f92cd555a925?d=identicon)[dvanscott](/maintainers/dvanscott)

---

Top Contributors

[![dvanscott](https://avatars.githubusercontent.com/u/38760117?v=4)](https://github.com/dvanscott "dvanscott (38 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")[![adrianrdz9](https://avatars.githubusercontent.com/u/32214527?v=4)](https://github.com/adrianrdz9 "adrianrdz9 (1 commits)")[![babacarcissedia](https://avatars.githubusercontent.com/u/17571380?v=4)](https://github.com/babacarcissedia "babacarcissedia (1 commits)")

---

Tags

filteringlaravellivewirelaravellivewirefilterskirschbaum-development

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/kirschbaum-development-livewire-filters/health.svg)

```
[![Health](https://phpackages.com/badges/kirschbaum-development-livewire-filters/health.svg)](https://phpackages.com/packages/kirschbaum-development-livewire-filters)
```

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[spatie/livewire-filepond

Upload files using Filepond in Livewire components

306452.7k3](/packages/spatie-livewire-filepond)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)[tomshaw/electricgrid

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

116.6k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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