{"id":13564988,"url":"https://github.com/spatie/nova-tags-field","last_synced_at":"2026-02-22T00:42:41.618Z","repository":{"id":32914009,"uuid":"145974148","full_name":"spatie/nova-tags-field","owner":"spatie","description":"A tags field to use in your Nova apps","archived":false,"fork":false,"pushed_at":"2024-12-30T10:19:41.000Z","size":2360,"stargazers_count":304,"open_issues_count":0,"forks_count":109,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-07T00:03:53.296Z","etag":null,"topics":["field","laravel","nova","php","tags"],"latest_commit_sha":null,"homepage":"https://freek.dev/a-tags-field-for-nova-apps","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://spatie.be/open-source/support-us"}},"created_at":"2018-08-24T09:49:45.000Z","updated_at":"2025-04-04T04:41:05.000Z","dependencies_parsed_at":"2024-01-14T03:49:27.876Z","dependency_job_id":"40c26129-a33b-44ce-9d3d-993fa400f96f","html_url":"https://github.com/spatie/nova-tags-field","commit_stats":{"total_commits":169,"total_committers":44,"mean_commits":3.840909090909091,"dds":0.5088757396449703,"last_synced_commit":"fac9701b4cc486722e4380f19ccb1de962e42177"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fnova-tags-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fnova-tags-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fnova-tags-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fnova-tags-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/nova-tags-field/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247740734,"owners_count":20988259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["field","laravel","nova","php","tags"],"created_at":"2024-08-01T13:01:38.890Z","updated_at":"2026-02-22T00:42:41.581Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://spatie.be/open-source/support-us"],"categories":["PHP"],"sub_categories":[],"readme":"# A tags field for Nova apps\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/nova-tags-field.svg?style=flat-square)](https://packagist.org/packages/spatie/nova-tags-field)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spatie/nova-tags-field/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/nova-tags-field.svg?style=flat-square)](https://packagist.org/packages/spatie/nova-tags-field)\n\nThis 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.\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/nova-tags-field.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/nova-tags-field)\n\nWe 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).\n\nWe 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).\n\n## Requirements\n\nThis Nova field requires MySQL 5.7.8 or higher.\n\n## Installation\n\nFirst 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.\n\nNext, you can install this package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:\n\n```bash\ncomposer require spatie/nova-tags-field\n```\n\n## Usage\n\nTo make an Eloquent model taggable just add the `\\Spatie\\Tags\\HasTags` trait to it:\n\n```php\nclass BlogPost extends \\Illuminate\\Database\\Eloquent\\Model\n{\n    use \\Spatie\\Tags\\HasTags;\n    \n    ...\n}\n```\n\nNext you can use the `Spatie\\TagsField\\Tags` field in your Nova resource:\n\n```php\nnamespace App\\Nova;\n\nuse Spatie\\TagsField\\Tags;\n\nclass BlogPost extends Resource\n{\n    // ...\n    \n    public function fields(NovaRequest $request)\n    {\n        return [\n            // ...\n            \n            Tags::make('Tags'),\n\n            // ...\n        ];\n    }\n}\n```\n\nNow you can view and add tags on the blog posts screen in your Nova app. All tags will be saved in the `tags` table. \n\n## Limiting suggestions\n\nBy 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()`.\n\n```php\nTags::make('Tags')-\u003ewithoutSuggestions(),\n```\n\nYou can change the number of suggestions with `limitSuggestions()`.\n\n```php\nTags::make('Tags')-\u003elimitSuggestions($maxNumberOfSuggestions),\n```\n\n## Limiting tags\n\nBy default a tags field will let you add unlimited tags. You can limit tags with `limit()`.\n\n```php\nTags::make('Tags')-\u003elimit($maxNumberOfTags),\n```\n\n## Using types\n\nThe [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.\n\n```php\n// in your Nova resource\n\npublic function fields(NovaRequest $request)\n{\n    return [\n        // ...\n        \n        Tags::make('Tags')-\u003etype('my-special-type'),\n\n        // ...\n    ];\n}\n```\n\n## Allowing only one tag\n\nIf the user is only allowed to select one tag for your resource you can call the `single` method.\n\n```php\n// in your Nova resource\n\npublic function fields(NovaRequest $request)\n{\n    return [\n        // ...\n        \n        Tags::make('Tags')-\u003esingle(),\n\n        // ...\n    ];\n}\n```\n\nThe field will be rendered as a select form element. It will be populated by the names of the tags already saved.\n\nIf you want to be able to deselect a tag, you can call the `canBeDeselected` method.\n\n```php\n// in your Nova resource\n\npublic function fields(NovaRequest $request)\n{\n    return [\n        // ...\n        \n        Tags::make('Tags')-\u003esingle()-\u003ecanBeDeselected(),\n\n        // ...\n    ];\n}\n```\n\n## Use a different placeholder\n\nYou 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...')`.\n\n```php\n// in your Nova resource\n\npublic function fields(NovaRequest $request)\n{\n    return [\n        // ...\n        \n        Tags::make('Categories', 'tags')-\u003ewithMeta(['placeholder' =\u003e 'Add categories...']),\n\n        // ...\n    ];\n}\n```\n\n## Working with tags\n\nFor 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/).\n\n## Administering tags in Nova\n\nIf you want to perform crud actions on the save tags, just create a Nova resource for it. Here's an example.\n\n```php\nnamespace App\\Nova;\n\nuse Laravel\\Nova\\Fields\\Text;\nuse Laravel\\Nova\\Http\\Requests\\NovaRequest;\nuse Spatie\\Tags\\Tag as TagModel;\n\nclass Tag extends Resource\n{\n    public static $model = TagModel::class;\n\n    public static $title = 'name';\n\n    public static $search = [\n        'name',\n    ];\n\n    public function fields(NovaRequest $request)\n    {\n        return [\n            Text::make('Name')-\u003esortable(),\n        ];\n    }\n}\n```\n\n### Show tags with a link to a Nova resource\n\nWhen creating the field, you can use the `withLinkToTagResource` method.  \nExample:\n```php\nTags::make('Tags')-\u003ewithLinkToTagResource() // The resource App\\Nova\\Tag will be used\nTags::make('Tags')-\u003ewithLinkToTagResource(\\Custom\\CustomTag::class) // The resource \\Custom\\CustomTag will be used\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n### Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n\nThe 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/).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fnova-tags-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fnova-tags-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fnova-tags-field/lists"}