Spotlight-like UI for Your Laravel Applications

Packages

July 2nd, 2021

Spotlight-like UI for Your Laravel Applications

Livewire UI Spotlight is a Livewire component that provides Spotlight/Alfred-like launcher to your Laravel applications:

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.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.