wire-elements/spotlight
Livewire Spotlight adds an Alfred-like command palette to Laravel. Open with configurable keyboard shortcuts or toggle via events, then search, navigate, and run actions from a sleek input bar. Easy Composer install and Livewire directive.
SpotlightCommand), aligning with Laravel’s service container and dependency injection patterns. This promotes clean architecture and testability.dispatch, dispatchBrowserEvent) for inter-component communication, reducing tight coupling between Spotlight and other parts of the app.composer require, @livewire directive), with zero database migrations or complex setup.SpotlightCommand to add domain-specific actions (e.g., "Create Invoice," "Search Users").shouldBeShown().| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Livewire Version | Requires Livewire v2+ (v3 recommended). | Verify compatibility with your Livewire version; test on a staging environment. |
| Alpine.js Dependency | Livewire v2 needs Alpine; v3 includes it natively. | For v3, no action needed. For v2, add Alpine via CDN or bundle. |
| Performance | Heavy command lists or complex dependencies may slow UI. | Lazy-load commands; optimize search{Dependency} queries (e.g., paginate results). |
| State Management | Livewire state persistence may cause issues with rapid Spotlight usage. | Test with frequent toggles; use wire:ignore if needed. |
| CSS Conflicts | Tailwind-centric by default; may clash with non-Tailwind apps. | Set include_css: true in config or override published views. |
| Dependency Bloat | Fuse.js (for fuzzy search) adds ~10KB to JS bundle. | Bundle Fuse.js separately if using custom JS setup. |
@livewire directive).dispatchBrowserEvent or Alpine’s $dispatch).shouldBeShown() or Gates/Policies).search{Dependency} methods).| Step | Action | Notes |
|---|---|---|
| 1. Prerequisites | Ensure Livewire v2+ and Laravel 8+. | Livewire v3 preferred; v2 requires Alpine.js. |
| 2. Installation | composer require wire-elements/spotlight |
Add @livewire('livewire-ui-spotlight') to layout. |
| 3. Configuration | Publish config/views/translations if needed: | Run php artisan vendor:publish --tag=livewire-ui-spotlight-{config/views/translations}. |
| 4. Command Development | Create commands with php artisan make:spotlight. |
Start with simple commands (e.g., "Logout"), then add dependencies. |
| 5. Integration Testing | Test shortcuts (Ctrl/Cmd+K), JS triggers, and command execution. | Verify shouldBeShown() logic for auth-sensitive commands. |
| 6. Optimization | Bundle JS/CSS if not using Tailwind or CDN. | Set include_js: false and manually include Fuse.js. |
| 7. Deployment | Deploy with feature flag (optional) to monitor performance. | Use Spotlight::registerCommandIf() for gradual rollout. |
dispatchBrowserEvent instead of dispatch.vendor:publish for non-Tailwind apps.@livewire directive, test shortcuts.shouldBeShown()).livewire-ui-spotlight.php (e.g., shortcuts, CSS/JS inclusion).$this->dispatch() events can be logged for troubleshooting.shouldBeShown() to debug auth/permission issues.search{Dependency} queries; add pagination.Spotlight::emit() or Livewire’s wire:error events.execute() logic in try-catch for graceful failures.Spotlight::registerCommandIf(auth()->check())).search{Dependency} results if data is static.| Failure Scenario
How can I help you explore Laravel packages today?