Skip to main content

Introduction

The tags input component allows you to interact with a list of tags. By default, tags are stored in JSON:
If you’re saving the JSON tags using Eloquent, you should be sure to add an array cast to the model property:
Filament also supports spatie/laravel-tags. See our plugin documentation for more information.

Comma-separated tags

You may allow the tags to be stored in a separated string, instead of JSON. To set this up, pass the separating character to the separator() method:

Autocompleting tag suggestions

Tags inputs may have autocomplete suggestions. To enable this, pass an array of suggestions to the suggestions() method:

Defining split keys

Split keys allow you to map specific buttons on your user’s keyboard to create a new tag. By default, when the user presses “Enter”, a new tag is created in the input. You may also define other keys to create new tags, such as “Tab” or ” ”. To do this, pass an array of keys to the splitKeys() method:
You can read more about possible options for keys.

Adding a prefix and suffix to individual tags

You can add prefix and suffix to tags without modifying the real state of the field. This can be useful if you need to show presentational formatting to users without saving it. This is done with the tagPrefix() or tagSuffix() method:

Reordering tags

You can allow the user to reorder tags within the field using the reorderable() method:
Optionally, you may pass a boolean value to control if the tags should be reorderable or not:

Changing the color of tags

You can change the color of the tags by passing a color to the color() method:

Trimming whitespace

You can automatically trim whitespace from the beginning and end of each tag using the trim() method:
You may want to enable trimming globally for all tags inputs, similar to Laravel’s TrimStrings middleware. You can do this in a service provider using the configureUsing() method:

Tags validation

You may add validation rules for each tag by passing an array of rules to the nestedRecursiveRules() method: