Skip to main content
The tags input component allows you to interact with a list of tags.

Basic Usage

use Filament\Forms\Components\TagsInput;

TagsInput::make('tags')

Available Methods

separator
method
Stores tags as separated string instead of JSON.
TagsInput::make('tags')
    ->separator(',')
suggestions
method
Adds autocomplete suggestions.
TagsInput::make('tags')
    ->suggestions([
        'tailwindcss',
        'alpinejs',
        'laravel',
        'livewire',
    ])
splitKeys
method
Sets keys that create new tags.
TagsInput::make('tags')
    ->splitKeys(['Tab', ' '])
tagPrefix
method
Adds prefix to displayed tags.
TagsInput::make('hashtags')
    ->tagPrefix('#')
tagSuffix
method
Adds suffix to displayed tags.
TagsInput::make('percentages')
    ->tagSuffix('%')
reorderable
method
Allows reordering tags.
TagsInput::make('tags')
    ->reorderable()
color
method
Sets the color of tags.
TagsInput::make('tags')
    ->color('primary')
trim
method
Trims whitespace from tags.
TagsInput::make('tags')
    ->trim()
nestedRecursiveRules
method
Adds validation rules for each tag.
TagsInput::make('tags')
    ->nestedRecursiveRules([
        'min:3',
        'max:255',
    ])

Common Patterns

Blog Post Tags

TagsInput::make('tags')
    ->suggestions([
        'laravel',
        'php',
        'javascript',
        'vue',
        'react',
    ])
    ->color('primary')

Hashtags

TagsInput::make('hashtags')
    ->tagPrefix('#')
    ->splitKeys(['Tab', ' ', ','])
    ->nestedRecursiveRules(['alpha_dash'])

Keywords

TagsInput::make('keywords')
    ->reorderable()
    ->separator(',')
    ->trim()

Categories

TagsInput::make('categories')
    ->suggestions([
        'Technology',
        'Business',
        'Science',
        'Health',
    ])
    ->color('success')

Database Casting

For JSON storage, add an array cast:
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected function casts(): array
    {
        return [
            'tags' => 'array',
        ];
    }
}

Build docs developers (and LLMs) love