Overview
This guide will walk you through creating a basic search interface using Interface X components. By the end, you’ll have a working search box with query suggestions and results display.Before starting, make sure you’ve completed the Installation guide.
What You’ll Build
In this quickstart, you’ll create a search interface with:- A search input field with auto-suggestions
- Query suggestions as users type
- A results list that displays search results
- Clear search functionality
Step-by-Step Guide
Set up the X Plugin
First, install the X Plugin in your Vue application. Create or update your This sets up the X Plugin with the Platform Adapter for connecting to your search API.
main.ts file:main.ts
Create the Search Interface Component
Create a new Vue component for your search interface. This component will include the search box and results:
SearchInterface.vue
Import Required Components
The components used in this example come from different X Modules:
All components are exported from the main
@empathyco/x-components package for easy importing.Test Your Search Interface
Start your development server and test the search functionality:Try the following interactions:
- Type in the search box - You should see query suggestions appear
- Click a suggestion - The search should execute automatically
- View results - Product results should display in a grid
- Clear the search - Click the Clear button to reset
Understanding the Components
SearchInput
TheSearchInput component provides the main search field with built-in features:
instant: Whentrue, automatically triggers search as you typeinstant-debounce-in-ms: Delay in milliseconds before triggering instant search (prevents excessive API calls)max-length: Maximum character limit for the search queryautofocus: Automatically focus the input when the component mounts
QuerySuggestions
Displays query suggestions based on what the user types:ResultsList
Renders search results with customizable item templates:Component State Management
Interface X uses Vuex for state management. Each component automatically connects to the appropriate store module:SearchInput→searchBoxmoduleQuerySuggestions→querySuggestionsmoduleResultsList→searchmodule
useState composable:
Event System
Interface X components communicate through an event bus. Common events include:UserAcceptedAQuery- User submitted a search queryUserIsTypingAQuery- User is typing in the search boxUserClickedAResult- User clicked on a search resultUserClearedQuery- User cleared the search
use$x composable:
Next Steps
Now that you have a basic search interface working, explore these features:Add Facets & Filters
Let users refine search results with filters
Popular Searches
Display trending searches to inspire users
Recommendations
Show personalized product recommendations
History Queries
Display user’s recent search history
Advanced Configuration
Configure Multiple Modules
You can configure specific X Modules during installation:Custom Adapter Configuration
If you’re using a custom search API, create your own adapter:Troubleshooting
No suggestions appearing
No suggestions appearing
Ensure:
- Your search API supports query suggestions
- The adapter is correctly configured
- You’re typing at least 2-3 characters
- Check browser console for API errors
Results not displaying
Results not displaying
Common issues:
- Verify your
scopeandinstanceconfiguration - Check network tab for API responses
- Ensure results data matches expected format
- Try a known working query first
Components not styled
Components not styled
Interface X components come with minimal styling. Options:
- Add your own CSS (as shown above)
- Install
@empathyco/x-tailwindcssfor the design system - Use CSS frameworks like Tailwind or Bootstrap
For more examples, check out the X Archetype - a complete reference implementation showing all Interface X capabilities.
