Introduction
Global search allows users to search across all resource records from anywhere in your admin panel. It appears in the topbar (or sidebar) and returns results from multiple resources.
Enabling Global Search
Set a record title attribute on your resource:
protected static ?string $recordTitleAttribute = 'title';
This attribute identifies records in search results.
Your resource must have an Edit or View page for global search to work. Without a page to link to, no results will be returned.
Search Result Titles
Customize how record titles appear:
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Model;
public static function getGlobalSearchResultTitle(Model $record): string | Htmlable
{
return $record->name;
}
Return HTML or Markdown:
use Illuminate\Support\HtmlString;
public static function getGlobalSearchResultTitle(Model $record): Htmlable
{
return new HtmlString(
"<strong>{$record->name}</strong> <span class='text-gray-500'>#{$record->id}</span>"
);
}
Searching Multiple Columns
Search across multiple attributes using dot notation for relationships:
public static function getGloballySearchableAttributes(): array
{
return ['title', 'slug', 'author.name', 'category.name'];
}
Search Result Details
Show additional information below the title:
use Illuminate\Database\Eloquent\Model;
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'Author' => $record->author->name,
'Category' => $record->category->name,
'Status' => $record->status->getLabel(),
];
}
Prevent N+1 queries by eager loading relationships:
use Illuminate\Database\Eloquent\Builder;
public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()
->with(['author', 'category']);
}
Custom Result URLs
By default, results link to the Edit page (or View page if the user lacks edit permissions).
Customize this:
use Illuminate\Database\Eloquent\Model;
public static function getGlobalSearchResultUrl(Model $record): string
{
return UserResource::getUrl('view', ['record' => $record]);
}
Search Result Actions
Add buttons below each search result:
use Filament\Actions\Action;
use Illuminate\Database\Eloquent\Model;
public static function getGlobalSearchResultActions(Model $record): array
{
return [
Action::make('edit')
->url(static::getUrl('edit', ['record' => $record]))
->icon('heroicon-m-pencil-square'),
Action::make('view')
->url(static::getUrl('view', ['record' => $record]))
->icon('heroicon-m-eye'),
];
}
Opening URLs in New Tabs
Action::make('view')
->url(static::getUrl('view', ['record' => $record]), shouldOpenInNewTab: true)
->icon('heroicon-m-arrow-top-right-on-square')
Dispatching Livewire Events
Action::make('quickView')
->dispatch('quickView', [$record->id])
->icon('heroicon-m-eye')
Limiting Results
By default, 50 results are shown per resource. Customize this:
protected static int $globalSearchResultsLimit = 20;
Sorting Results
Control the order in which resource results appear:
protected static ?int $globalSearchSort = 3;
Lower numbers appear first.
Global Search Position
By default, global search is in the topbar. Move it to the sidebar:
use Filament\Enums\GlobalSearchPosition;
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
->globalSearch(position: GlobalSearchPosition::Sidebar)
// ...
}
Search Configuration
Key Bindings
Set keyboard shortcuts to open search:
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
->globalSearchKeyBindings(['command+k', 'ctrl+k'])
// ...
}
Debounce
Control how long to wait before searching:
public function panel(Panel $panel): Panel
{
return $panel
->globalSearchDebounce('750ms')
// ...
}
Field Suffix
Show the keyboard shortcut in the search field:
public function panel(Panel $panel): Panel
{
return $panel
->globalSearchFieldKeyBindingSuffix()
// ...
}
Or customize it:
use Filament\Support\Enums\Platform;
public function panel(Panel $panel): Panel
{
return $panel
->globalSearchFieldSuffix(fn (): ?string => match (Platform::detect()) {
Platform::Windows, Platform::Linux => 'CTRL+K',
Platform::Mac => '⌘K',
default => null,
})
// ...
}
Disabling Global Search
Disable it entirely:
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
->globalSearch(false)
// ...
}
Or for specific resources:
protected static bool $isGloballySearchable = false;
Search Term Splitting
By default, search terms are split into words. This allows flexible queries but may impact performance on large datasets.
Disable splitting:
protected static ?bool $shouldSplitGlobalSearchTerms = false;
Advanced Search Queries
Customize the search query:
use Illuminate\Database\Eloquent\Builder;
public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()
->where('status', 'published')
->with(['author', 'category'])
->withCount('comments');
}
Examples
Blog Posts
Customers
Products
protected static ?string $recordTitleAttribute = 'title';
protected static int $globalSearchResultsLimit = 10;
public static function getGloballySearchableAttributes(): array
{
return ['title', 'slug', 'content', 'author.name'];
}
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'Author' => $record->author->name,
'Published' => $record->published_at?->format('M j, Y'),
];
}
public static function getGlobalSearchEloquentQuery(): Builder
{
return parent::getGlobalSearchEloquentQuery()
->where('status', 'published')
->with('author');
}
protected static ?string $recordTitleAttribute = 'name';
public static function getGloballySearchableAttributes(): array
{
return ['name', 'email', 'phone', 'company'];
}
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'Email' => $record->email,
'Company' => $record->company,
];
}
public static function getGlobalSearchResultActions(Model $record): array
{
return [
Action::make('edit')
->url(static::getUrl('edit', ['record' => $record])),
Action::make('email')
->url("mailto:{$record->email}")
->icon('heroicon-m-envelope'),
];
}
protected static ?string $recordTitleAttribute = 'name';
public static function getGlobalSearchResultTitle(Model $record): Htmlable
{
return new HtmlString(
$record->name .
" <span class='text-sm text-gray-500'>#{$record->sku}</span>"
);
}
public static function getGloballySearchableAttributes(): array
{
return ['name', 'sku', 'description', 'category.name'];
}
public static function getGlobalSearchResultDetails(Model $record): array
{
return [
'SKU' => $record->sku,
'Category' => $record->category->name,
'Price' => '$' . number_format($record->price, 2),
];
}