PHPackages                             juniorfontenele/spatie-nova-tags-field - 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. juniorfontenele/spatie-nova-tags-field

ActiveLibrary

juniorfontenele/spatie-nova-tags-field
======================================

A tags field for Nova apps

v4.0.0(4y ago)07MITPHPPHP ^8.0|^7.3

Since Aug 24Pushed 4y agoCompare

[ Source](https://github.com/juniorfontenele/nova-tags-field)[ Packagist](https://packagist.org/packages/juniorfontenele/spatie-nova-tags-field)[ Docs](https://github.com/spatie/nova-tags-field)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/juniorfontenele-spatie-nova-tags-field/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (5)Versions (40)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

A tags field for Nova apps
==========================

[](#a-tags-field-for-nova-apps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/438a0371d716407128efe98ba92b481fe89de8a1513635684dff0340b85dbaf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6e6f76612d746167732d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/nova-tags-field)[![GitHub Workflow Status](https://camo.githubusercontent.com/946172b398d2f7a2462adb6035e5e78cf03a1ad53f8e13704c5209db9826fc61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6e6f76612d746167732d6669656c642f72756e2d74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/946172b398d2f7a2462adb6035e5e78cf03a1ad53f8e13704c5209db9826fc61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6e6f76612d746167732d6669656c642f72756e2d74657374733f6c6162656c3d7465737473)[![Total Downloads](https://camo.githubusercontent.com/e6ee5c7e8ff63c9629aa4f144cd5cf3c89afdd5a2ebe7781b8033474f2abae4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6e6f76612d746167732d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/nova-tags-field)

This package contains a Nova field to add tags to resources. Under the hood it uses the [spatie/laravel-tags](https://docs.spatie.be/laravel-tags) package.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/47bc7fcd150b59c95d74a8d2496f4d1a5a392e86e7480a621cb107b4d98689f3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6e6f76612d746167732d6669656c642e6a70673f743d31)](https://spatie.be/github-ad-click/nova-tags-field)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#requirements)

This Nova field requires MySQL 5.7.8 or higher.

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

[](#installation)

First you must install [spatie/laravel-tags](https://github.com/spatie/laravel-tags) into your Laravel app. Here are [the installation instructions](https://spatie.be/docs/laravel-tags/v4/installation-and-setup) for that package.

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

```
composer require spatie/nova-tags-field
```

Usage
-----

[](#usage)

To make an Eloquent model taggable just add the `\Spatie\Tags\HasTags` trait to it:

```
class BlogPost extends \Illuminate\Database\Eloquent\Model
{
    use \Spatie\Tags\HasTags;

    ...
}
```

Next you can use the `Spatie\TagsField\Tags` field in your Nova resource:

```
namespace App\Nova;

use Spatie\TagsField\Tags;

class BlogPost extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            Tags::make('Tags'),

            // ...
        ];
    }
}
```

Now you can view and add tags on the blog posts screen in your Nova app. All tags will be saved in the `tags` table.

Limiting suggestions
--------------------

[](#limiting-suggestions)

By default a tags field will display a maximum of 5 suggestions when typing into it. If you don't want to display any suggestions, tag on `withoutSuggestions()`.

```
Tags::make('Tags')->withoutSuggestions(),
```

You can change the number of suggestions with `limitSuggestions()`.

```
Tags::make('Tags')->limitSuggestions($maxNumberOfSuggestions),
```

Limiting tags
-------------

[](#limiting-tags)

By default a tags field will let you add unlimited tags. You can limit tags with `limit()`.

```
Tags::make('Tags')->limit($maxNumberOfTags),
```

Using types
-----------

[](#using-types)

The [underlying tags package](https://github.com/spatie/laravel-tags) has support for [tag types](https://docs.spatie.be/laravel-tags/v2/advanced-usage/using-types). To make your tags field save tags of a certain type just tack on the name of type when adding the field to your Nova resource.

```
// in your Nova resource

public function fields(Request $request)
{
    return [
        // ...

        Tags::make('Tags')->type('my-special-type'),

        // ...
    ];
}
```

Allowing only one tag
---------------------

[](#allowing-only-one-tag)

If the user is only allowed to select one tag for your resource you can call the `single` method.

```
// in your Nova resource

public function fields(Request $request)
{
    return [
        // ...

        Tags::make('Tags')->single(),

        // ...
    ];
}
```

The field will be rendered as a select form element. It will be populated by the names of the tags already saved.

If you want to be able to deselect a tag, you can call the `canBeDeselected` method.

```
// in your Nova resource

public function fields(Request $request)
{
    return [
        // ...

        Tags::make('Tags')->single()->canBeDeselected(),

        // ...
    ];
}
```

Use a different placeholder
---------------------------

[](#use-a-different-placeholder)

You can use the `withMeta` method [documented here](https://nova.laravel.com/docs/3.0/customization/fields.html#field-options) to change the placeholder from the default, which is `__('Add tags...')`.

```
// in your Nova resource

public function fields(Request $request)
{
    return [
        // ...

        Tags::make('Categories', 'tags')->withMeta(['placeholder' => 'Add categories...']),

        // ...
    ];
}
```

Working with tags
-----------------

[](#working-with-tags)

For more info on how to work with the saved tags, head over to [the docs of spatie/laravel-tags](https://docs.spatie.be/laravel-tags/).

Administering tags in Nova
--------------------------

[](#administering-tags-in-nova)

If you want to perform crud actions on the save tags, just create a Nova resource for it. Here's an example.

```
namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Spatie\Tags\Tag as TagModel;

class Tag extends Resource
{
    public static $model = TagModel::class;

    public static $title = 'name';

    public static $search = [
        'name',
    ];

    public function fields(Request $request)
    {
        return [
            Text::make('Name')->sortable(),
        ];
    }
}
```

### Show tags with a link to a Nova resource

[](#show-tags-with-a-link-to-a-nova-resource)

When creating the field, you can use the `withLinkToTagResource` method.
Example:

```
Tags::make('Tags')->withLinkToTagResource() // The resource App\Nova\Tag will be used
Tags::make('Tags')->withLinkToTagResource(\Custom\CustomTag::class) // The resource \Custom\CustomTag will be used
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

### Security

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)

The Vue components that render the tags are based upon the tag Vue components created by [Adam Wathan](https://twitter.com/adamwathan) as shown in [his excellent Advanced Vue Component Design course](https://adamwathan.me/advanced-vue-component-design/).

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 50.7% 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 ~35 days

Recently: every ~21 days

Total

38

Last Release

1497d ago

Major Versions

0.1.4 → 1.0.02018-09-14

1.1.3 → 2.0.02019-02-11

2.3.4 → 3.0.02020-03-03

3.4.5 → v4.0.02022-04-06

PHP version history (2 changes)0.0.1PHP &gt;=7.1.0

3.1.0PHP ^8.0|^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3694405?v=4)[Junior Fontenele](/maintainers/juniorfontenele)[@juniorfontenele](https://github.com/juniorfontenele)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (77 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (9 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![bastihilger](https://avatars.githubusercontent.com/u/1419634?v=4)](https://github.com/bastihilger "bastihilger (8 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (6 commits)")[![persteinhorst](https://avatars.githubusercontent.com/u/6418121?v=4)](https://github.com/persteinhorst "persteinhorst (3 commits)")[![lucidlogic](https://avatars.githubusercontent.com/u/932221?v=4)](https://github.com/lucidlogic "lucidlogic (3 commits)")[![depsimon](https://avatars.githubusercontent.com/u/1822289?v=4)](https://github.com/depsimon "depsimon (3 commits)")[![juniorfontenele](https://avatars.githubusercontent.com/u/3694405?v=4)](https://github.com/juniorfontenele "juniorfontenele (2 commits)")[![willymiiee](https://avatars.githubusercontent.com/u/4866072?v=4)](https://github.com/willymiiee "willymiiee (2 commits)")[![jesseschutt](https://avatars.githubusercontent.com/u/353047?v=4)](https://github.com/jesseschutt "jesseschutt (2 commits)")[![aliozgurr](https://avatars.githubusercontent.com/u/25711333?v=4)](https://github.com/aliozgurr "aliozgurr (2 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")[![t1sh0o](https://avatars.githubusercontent.com/u/3911728?v=4)](https://github.com/t1sh0o "t1sh0o (1 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")[![tzsk](https://avatars.githubusercontent.com/u/13273787?v=4)](https://github.com/tzsk "tzsk (1 commits)")[![zupolgec](https://avatars.githubusercontent.com/u/161318?v=4)](https://github.com/zupolgec "zupolgec (1 commits)")[![cfreear](https://avatars.githubusercontent.com/u/619726?v=4)](https://github.com/cfreear "cfreear (1 commits)")[![everestmx](https://avatars.githubusercontent.com/u/5403326?v=4)](https://github.com/everestmx "everestmx (1 commits)")

---

Tags

laravelnova

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/juniorfontenele-spatie-nova-tags-field/health.svg)

```
[![Health](https://phpackages.com/badges/juniorfontenele-spatie-nova-tags-field/health.svg)](https://phpackages.com/packages/juniorfontenele-spatie-nova-tags-field)
```

###  Alternatives

[spatie/nova-tags-field

A tags field for Nova apps

3021.9M7](/packages/spatie-nova-tags-field)[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2872.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2861.8M9](/packages/outl1ne-nova-sortable)[laravel/nova-log-viewer

A Laravel Nova tool for viewing your application logs.

136301.3k1](/packages/laravel-nova-log-viewer)[stepanenko3/nova-command-runner

Laravel Nova tool for running Artisan and bash(shell) commands.

36983.0k](/packages/stepanenko3-nova-command-runner)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)

PHPackages © 2026

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