wezlo/filament-search-spotlight
Full-screen Spotlight/command-palette search for Filament panels (⌘K/Ctrl+K). Aggregates global search records plus resources, pages, and actions, with recent/pinned items stored in localStorage. Keyboard navigation, configurable per panel and via config.
Installation:
composer require wezlo/filament-search-spotlight
Register the plugin in your Filament panel:
FilamentSearchSpotlightPlugin::make(),
First Use Case:
⌘K (or your configured shortcut) to open the spotlight overlay.Enter, and close with Esc.Tailwind Setup (if applicable): Add the package’s views to your Tailwind scan:
@source '../../../../vendor/wezlo/filament-search-spotlight/resources/views/**/*';
Rebuild assets (npm run build or npm run dev).
Default Usage: Register the plugin in your panel’s PanelProvider:
->plugins([
FilamentSearchSpotlightPlugin::make(),
])
This enables all built-in categories (records, resources, pages, actions) with default settings.
Custom Shortcut:
FilamentSearchSpotlightPlugin::make()
->keyBinding('ctrl+k') // Override default ⌘K
FilamentSearchSpotlightPlugin::make()
->records() // Show records (default: true)
->resources(false) // Hide resources
->categories([CustomCategory::class, RecordsCategory::class])
// In AppServiceProvider::boot()
SpotlightAction::make('clear-cache')
->label('Clear Cache')
->keywords(['cache', 'flush'])
->url(route('cache.clear'))
->register();
FilamentSearchSpotlightPlugin::make()
->action(
SpotlightAction::make('log-out')
->label('Log Out')
->icon('heroicon-o-arrow-right-on-rectangle')
->url(fn () => filament()->getLogoutUrl())
)
->excludeResources([AuditLogResource::class])
->disableDefaultGlobalSearch()
Category contract:
class SettingsCategory implements Category {
public function search(string $query, int $limit): array {
return collect($this->settings)
->filter(fn ($item) => str_contains(strtolower($item['name']), strtolower($query)))
->map(fn ($item) => new SpotlightResult(
id: 'settings:'.$item['id'],
title: $item['name'],
url: route('admin.settings.edit', $item['id']),
))
->take($limit)
->values()
->all();
}
}
->categories([SettingsCategory::class])
->maxWidth('40rem')
->placeholder('Quick search…')
Tailwind Purging:
.spotlight-overlay may be purged otherwise.Resource Exclusion:
->excludeResources()) also hides its auto-generated "Create {Resource}" action.->disableCreateActions().Action Overrides:
name.->overrideActions(['action-name']) to hide a global action without replacing it.LocalStorage Dependencies:
localStorage. If your app uses iframes or multiple windows, behavior may vary.Keyboard Conflicts:
mod+k) may conflict with other apps (e.g., VS Code). Test thoroughly.->keyBinding(['mod+k', 'ctrl+k'])
Performance with Large Datasets:
GlobalSearchProvider, which may impact performance for resources with many records.->resultLimitPerCategory(5)
Check Console for Errors:
F12) and monitor the console for JavaScript errors (e.g., missing Tailwind classes).Verify Plugin Registration:
PanelProvider.Test Action URLs:
dd() or dump() in action URL closures to debug routing issues:
->url(fn () => dd(route('admin.cache.clear')))
Inspect LocalStorage:
localStorage for spotlight.recent/spotlight.pinned to verify recent items persistence.Disable Categories Incrementally:
->records(false)
->resources(false)
Custom Result Rendering:
SpotlightResult class or extend it to add metadata (e.g., badges, timestamps).Dynamic Action Registration:
if (auth()->user()->isAdmin()) {
SpotlightAction::make('admin-dashboard')->url('/admin')->register();
}
Server-Side Recent Items:
Multi-Panel Support:
FilamentSearchSpotlightPlugin::make()
->keyBinding('mod+shift+k')
->placeholder('Panel B Search')
Testing:
php artisan test --compact tests/Feature/FilamentSearchSpotlight
$this->actingAs($user)
->spotlight()
->search('test')
->assertSee('Expected Result');
How can I help you explore Laravel packages today?