npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ducnd.dev/vue-autocomplete

v1.0.5

Published

A flexible and customizable autocomplete component for Vue 3 with TypeScript support.

Readme

Vue 3 Autocomplete Component

A flexible and customizable autocomplete component for Vue 3 with TypeScript support.

Features

  • 🔍 Search as you type with debounced input
  • Async data loading support
  • 🎨 Customizable option rendering with slots
  • ⌨️ Keyboard navigation (Arrow keys, Enter, Tab, Escape)
  • 🎯 TypeScript support with full type safety
  • 📱 Responsive design with loading states
  • 🚫 Exclude values functionality
  • 🔧 Highly configurable props

Installation

npm install @ducnd.dev/vue-autocomplete

Usage

Basic Usage

<template>
  <VAutoComplete
    v-model="selectedValue"
    :items="options"
    placeholder="Search..."
    label-key="name"
    value-key="id"
    @select="onSelect"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { VAutoComplete } from '@ducnd.dev/vue-autocomplete'
import '@ducnd.dev/vue-autocomplete/style.css'

const selectedValue = ref('')
const options = ref([
  { id: '1', name: 'Option 1' },
  { id: '2', name: 'Option 2' },
  { id: '3', name: 'Option 3' }
])

const onSelect = (option: any) => {
  console.log('Selected:', option)
}
</script>

Async Data Loading

<template>
  <VAutoComplete
    v-model="selectedValue"
    :fetch-options="fetchUsers"
    placeholder="Search users..."
    label-key="name"
    value-key="id"
    @select="onSelect"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { VAutoComplete } from '@ducnd.dev/vue-autocomplete'

interface User {
  id: string
  name: string
  email: string
}

const selectedValue = ref('')

const fetchUsers = async (query: string): Promise<User[]> => {
  const response = await fetch(`/api/users?q=${query}`)
  return response.json()
}

const onSelect = (user: User) => {
  console.log('Selected user:', user)
}
</script>

Custom Option Rendering

<template>
  <VAutoComplete
    v-model="selectedValue"
    :items="users"
    label-key="name"
    value-key="id"
  >
    <template #option="{ option }">
      <div class="user-option">
        <div class="user-name">{{ option.name }}</div>
        <div class="user-email">{{ option.email }}</div>
      </div>
    </template>
  </VAutoComplete>
</template>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | modelValue | string | '' | The current selected value (v-model) | | fetchOptions | (query: string) => Promise<T[]> | undefined | Async function to fetch options based on query | | items | T[] | [] | Static array of options | | placeholder | string | '' | Input placeholder text | | labelKey | string | 'label' | Key to use for displaying option text | | valueKey | string | 'value' | Key to use for option values | | excludeValues | string[] | [] | Array of values to exclude from results |

Events

| Event | Payload | Description | |-------|---------|-------------| | update:modelValue | string | Emitted when the selected value changes (v-model) | | select | T | Emitted when an option is selected | | search | string | Emitted when the user types in the input | | error | unknown | Emitted when an error occurs during async data loading |

Slots

| Slot | Props | Description | |------|-------|-------------| | option | { option: T } | Custom rendering for each option item |

Keyboard Navigation

  • Arrow Down/Up: Navigate through options
  • Enter/Tab: Select the highlighted option
  • Escape: Close the dropdown and blur input

Styling

The component uses scoped CSS that is automatically extracted during the build process.

Important: You must import the CSS file for styles to work:

import '@ducnd.dev/vue-autocomplete/style.css'

You can customize the component by overriding the CSS classes:

.autocomplete {
  /* Container */
}

.autocomplete-input {
  /* Input field */
}

.autocomplete-list {
  /* Dropdown list */
}

.autocomplete-item {
  /* Individual option */
}

.autocomplete-item.active {
  /* Highlighted option */
}

.loading-spinner {
  /* Loading indicator */
}

Note: The component uses scoped CSS attributes (e.g., data-v-xxxxxx), so you may need higher CSS specificity to override styles.

TypeScript Support

The component is fully typed and exports the necessary interfaces:

import type { VAutoCompleteProps } from '@ducnd.dev/vue-autocomplete'

interface MyOption {
  id: string
  name: string
}

// Props are properly typed based on your option type
const props: VAutoCompleteProps<MyOption> = {
  modelValue: '',
  items: [],
  labelKey: 'name',
  valueKey: 'id'
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.