PHPackages                             eolica/nova-pill-filter - 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. [Admin Panels](/categories/admin)
4. /
5. eolica/nova-pill-filter

AbandonedArchivedLibrary[Admin Panels](/categories/admin)

eolica/nova-pill-filter
=======================

A simple Laravel Nova filter that renders into clickable pills

1.0.0(5y ago)15.5k1MITVuePHP &gt;=7.2

Since Oct 29Pushed 5y agoCompare

[ Source](https://github.com/Eolica-Web/nova-pill-filter)[ Packagist](https://packagist.org/packages/eolica/nova-pill-filter)[ Docs](https://github.com/Eolica-Web/nova-pill-filter)[ RSS](/packages/eolica-nova-pill-filter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

A Laravel Nova filter that renders into clickable pills.
========================================================

[](#a-laravel-nova-filter-that-renders-into-clickable-pills)

A simple Laravel Nova filter that renders into colorful clickable pills. This filter is very inspired by [this other package](https://github.com/dcasia/nova-pill-filter), however we needed some extra features (like customizing the color of each pill) for client projects and that package seemed to not be maintained nor production ready, so we decided to make our own version of this filter.

[![Pill Filter](https://raw.githubusercontent.com/Eolica-Web/nova-pill-filter/master/docs/screenshots/screenshot_1.png)](https://raw.githubusercontent.com/Eolica-Web/nova-pill-filter/master/docs/screenshots/screenshot_1.png)

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

[](#installation)

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require eolica/nova-pill-filter
```

Usage
-----

[](#usage)

### Creating the filter

[](#creating-the-filter)

You may create a new pill filter manually and extending the `Eolica\NovaPillFilter\PillFilter` class:

```
namespace App\Nova\Filters;

use Illuminate\Http\Request;
use Eolica\NovaPillFilter\PillFilter;

final class MyPillFilter extends PillFilter
{
    public function apply(Request $request, $query, $value)
    {
        return $query;
    }

    public function options(Request $request)
    {
        return [];
    }
}
```

Or, even easier, using the following artisan command:

```
php artisan nova:pill-filter MyPillFilter
```

If you want to customize the "stub" the command uses to generate the filter class, you may use the following command to publish it:

```
php artisan nova:pill-filter-stubs
```

Next, we must register the filter within the `filters` method of our resource:

```
final class MyNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            Filters\MyPillFilter::make(),
        ];
    }
}
```

### Configuring the filter

[](#configuring-the-filter)

By default multiple items can be selected, you can restrict it to a single item at time by using the `single` method

```
final class MyNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            Filters\MyPillFilter::make()->single(),
        ];
    }
}
```

Also, the filter shows by default a "Clear" button when some item is active. When clicked, deactivates all items at once. If you want to hide the button you may use the `hideClearButton` method:

```
final class MyNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            Filters\MyPillFilter::make()->hideClearButton(),
        ];
    }
}
```

If you want the "Clear" button to show, you may also change the text within by using the `clearLabel` method, mainly for translation purposes:

```
final class MyNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            Filters\MyPillFilter::make()->clearLabel('Custom label'),
        ];
    }
}
```

Last, you may change the displaying mode of the filter, by default it wraps to show all pills at once, however you may change it to drag mode by using the `draggable` method:

```
final class MyNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            Filters\MyPillFilter::make()->draggable(),
        ];
    }
}
```

[![Pill Filter](https://raw.githubusercontent.com/Eolica-Web/nova-pill-filter/master/docs/screenshots/screenshot_2.png)](https://raw.githubusercontent.com/Eolica-Web/nova-pill-filter/master/docs/screenshots/screenshot_2.png)

### Configuring the filter options

[](#configuring-the-filter-options)

The most simple way is to return a key/value pair array, the key being the label displayed within the pill:

```
final class MyPillFilter extends PillFilter
{
    public function options(Request $request)
    {
        return [
            'Family'        => 'family',
            'Sea'           => 'sea',
            'Sports'        => 'sports',
            'City'          => 'city',
            'Eco'           => 'eco',
            'Countryside'   => 'countryside',
        ];
    }
}
```

You may customize each pill background color, text color, background color when active and text color when active, in this case the key of each option must be the value and the label text must be within the `label` key:

```
final class MyPillFilter extends PillFilter
{
    public function options(Request $request)
    {
        return [
            'family' => [
                'label'                 => 'Family',
                'color'                 => '#d53f8c', // Default '#3c4b5f'
                'backgroundColor'       => '#fbb6ce', // Default '#eef1f4'
                'colorActive'           => '#ffffff', // Default '#ffffff'
                'backgroundColorActive' => '#d53f8c', // Default '#4099de'
            ],
            'sea' => [
                'label'                 => 'Sea',
                'color'                 => '#3182ce',
                'backgroundColor'       => '#bee3f8',
                'colorActive'           => '#ffffff',
                'backgroundColorActive' => '#3182ce',
            ],
            'sports' => [
                'label'                 => 'Sports',
                'color'                 => '#e53e3e',
                'backgroundColor'       => '#fed7d7',
                'colorActive'           => '#ffffff',
                'backgroundColorActive' => '#e53e3e',
            ],
            ...
        ];
    }
}
```

### Applying the values to the query

[](#applying-the-values-to-the-query)

The filter will send you an `array` containing the values that are active.

```
final class MyPillFilter extends PillFilter
{
    public function apply(Request $request, $query, $values)
    {
        return $query->whereIn('lifestyle', $values); // $values is an array
    }
}
```

Changelog
---------

[](#changelog)

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

Security
--------

[](#security)

If you discover a security vulnerability within this package, please send an email at  instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2018d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ce7b6c97be6045063ccacafcc49a200b1066d5dfd5a125aec669687c1b8effb?d=identicon)[dllobell](/maintainers/dllobell)

---

Tags

laravelnova

### Embed Badge

![Health badge](/badges/eolica-nova-pill-filter/health.svg)

```
[![Health](https://phpackages.com/badges/eolica-nova-pill-filter/health.svg)](https://phpackages.com/packages/eolica-nova-pill-filter)
```

###  Alternatives

[khalin/nova-link-field

A Laravel Nova Link field.

31562.2k2](/packages/khalin-nova-link-field)[digital-creative/nova-dashboard

The missing dashboard for nova.

7169.3k1](/packages/digital-creative-nova-dashboard)[harrald/nova-combobox-filter

A Laravel Nova combobox filter. Supports selecting multiple items

13105.5k](/packages/harrald-nova-combobox-filter)[marianvlad/nova-ssl-card

A Laravel Nova card for SSL certificates.

1219.9k](/packages/marianvlad-nova-ssl-card)[shuvroroy/nova-dynamic-views

A tool for easier overwriting custom-header and toolbars in Laravel Nova

1025.7k](/packages/shuvroroy-nova-dynamic-views)

PHPackages © 2026

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