July 30, 2026 — The unofficial Laracon US Day 3. Get your ticket to The Vibes

You're viewing pre-release documentation — version 4.x is in beta

Features, APIs and behaviour may change before the stable release. View the stable version (3.x)

Search


Overview#

A screen can present a native search bar in its navigation chrome and feed it from PHP. There are two modes: a static corpus the platform filters for you, and a dynamic handler you implement for server- or database-backed results.

The search bar itself is shown by the layout chrome — via NavBar::searchBar() on a stack, or Tab::search() on a tab. This page covers the component side: producing the results.

Override searchItems() to return a fixed list the native search bar filters on-device as the user types — no round-trip per keystroke. Return null to omit search entirely.

Copied!
public function searchItems(): ?array
{
return Contact::pluck('name')->all();
}

Best for small, in-memory corpuses (a contact list, a settings index) where the whole set is cheap to hand over once.

For results that come from a query — anything too large to preload, or that hits the database or network — override onSearchQuery(). It receives the current query and returns the matching results; the native bar debounces input so you're not queried on every character.

Copied!
public function onSearchQuery(string $query): array
{
return Product::where('name', 'like', "%{$query}%")
->limit(20)
->pluck('name')
->all();
}

Add the bar in the layout chrome and point it at the screen. On a stack layout's NavBar:

Copied!
NavBar::make()
->title('Contacts')
->searchBar(placeholder: 'Search contacts', debounceMs: 300);

Or as a dedicated search tab:

Copied!
Tab::search('Search', icon: 'magnifyingglass', placeholder: 'Find anything');

See Layouts for where these builders live and how a layout wraps a screen.