Spotlight-like UI for Your Laravel Applications
Published on by Paul Redmond
Livewire UI Spotlight is a Livewire component that provides Spotlight/Alfred-like launcher to your Laravel applications:
Laravel Spotlight is now available 🎉
— Philo Hermans (@Philo01) April 22, 2021
Spotlight is a @LaravelLivewire component that provides Spotlight/Alfred-like functionality to your @laravelphp application. It really makes navigating through your app so much quicker. I would love to see this in many other applications😎 pic.twitter.com/fB7IJrdgYK
At the heart of using this package is creating spotlight commands for your application that users can execute. For example, the readme provides a snippet for logging a user out via the Spotlight component:
<?php namespace LivewireUI\Spotlight\Commands; use Illuminate\Contracts\Auth\StatefulGuard;use LivewireUI\Spotlight\Spotlight;use LivewireUI\Spotlight\SpotlightCommand; class Logout extends SpotlightCommand{ protected string $name = 'Logout'; protected string $description = 'Logout out of your account'; public function execute(Spotlight $spotlight, StatefulGuard $guard): void { $guard->logout(); $spotlight->redirect('/'); }}
As Mac users are used to the CMD + Space shortcut to trigger Spotlight/Alfred, this component defaults to CTRL/CMD + K
or CTRL/CMD + /
, and these shortcuts are customizable from a published package configuration.
You can also trigger spotlight programmatically in any Livewire component:
$this->dispatchBrowserEvent('toggle-spotlight');
Or via Alpine within your markup:
<button @click="$dispatch('toggle-spotlight')">Toggle Spotlight</button>
The use-cases are endless with this component to make your application more accessible to power users and desktop-like experiences. You can learn more about this package, get full installation instructions, and view the source code on GitHub.