A name search component with suggestions, built with Vue 3 and TypeScript. Perfect for projects requiring autocomplete search functionality.

- Vue 3 (Composition API)
- TypeScript
- Vite (Bbild and development)
- SCSS (Styling framework)
- Vitest (Testing)
- ESLint, Prettier, Stylelint (Linting and formatting)
- Husky, lint-staged, commitlint, Commitizen (Commit checks and formatting)
This component provides functionality for name search with suggestions. The user types into the search field, and the component automatically displays matching results that can be selected using the mouse or keyboard.
Features:
- Highlighting of matched results.
- Support for navigation keys (
ArrowUp
,ArrowDown
,Enter
,Escape
). - Debounce functionality to improve performance.
- A responsive and accessible interface for screen readers.
You can see an example of the component in action in the available demo.
git clone https://github.com/vofronte/vue-3-search-name.git
cd vue-3-search-name
yarn install
yarn dev
The project will be available at http://localhost:5173.
Run the tests:
yarn test
-
Linting (ESLint + Stylelint):
yarn lint
-
Formatting (Prettier):
yarn format
yarn commit
This script runs Commitizen and helps you create commits with the correct format.
yarn build
<NameSearch @select="handleNameSelect" />
Example handler for name selection:
const handleNameSelect = (name: string | null) => {
console.log('Selected name:', name)
}
inputId
: A unique identifier for the input field.names
: An array of names to search.debounceMs
: Debounce delay in milliseconds before performing the search.
Vitest is used for testing. You can run the tests using the yarn test
command.