Sometimes, we do not want things to be placed in the default position. In this case, we are talking about a search bar. But did you know that you can easily move it to the sidebar?
Get the Source Code:
Only This Example
One-time payment
Sign in with GitHub to buy
Sign in first, then complete your $9 checkout.
FilamentExamples Membership
30-day money-back guarantee
How it works
Since Filament v4.1, moving search to the sidebar can be done by setting it in the Panel Provider. Check the official documentation
To show search in the sidebar, we use the SIDEBAR_NAV_START Render Hook to add a GlobalSearch Livewire component.
app/Providers/AppServiceProvider.php:
use Filament\View\PanelsRenderHook;use Illuminate\Support\Facades\Blade;use Illuminate\Support\ServiceProvider;use Filament\Support\Facades\FilamentView; class AppServiceProvider extends ServiceProvider{ // ... public function boot(): void { FilamentView::registerRenderHook( PanelsRenderHook::SIDEBAR_NAV_START, fn (): string => Blade::render('@livewire(Filament\Livewire\GlobalSearch::class, [\'lazy\' => true])'), ); }}
To fix the styling issue, a custom theme must be created and registered.