SearchBarInput container
The SearchBarInput
container provides a search input interface with real-time search suggestions and debounced search functionality. It handles user input, triggers search requests, and manages loading and error states.
Configurations
The SearchBarInput
container provides the following configuration options:
Slots
The SearchBarInput
container supports the following slots:
- InputForm - Replaces the entire search input form component
- SearchIcon - Customizes the search icon displayed in the input field
Features
Debounced search
The container uses debounced search functionality to prevent excessive API calls while the user is typing. The debounce delay can be configured via the debounceDelay
prop.
Minimum query length
Search suggestions are only triggered when the query length meets or exceeds the minimumQueryLength
threshold, helping to reduce unnecessary API calls for very short queries.
Loading and error states
The container manages loading states during search operations and handles error scenarios, providing feedback to the user through the search input component.
Event integration
The container integrates with the Adobe Commerce event bus to emit search-related events that other components can listen to and respond accordingly.
Example
import { SearchBarInput } from '@adobe-commerce/storefront-search-dropin';
function SearchPage() { const handleRouteSearch = (query) => { // Navigate to search results page window.location.href = `/search?q=${encodeURIComponent(query)}`; };
return ( <SearchBarInput searchQuery="" minimumQueryLength={2} debounceDelay={250} defaultQueryPlaceholder="Search products..." routeSearch={handleRouteSearch} slots={{ SearchIcon: { component: CustomSearchIcon } }} /> );}