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

@tomickigrzegorz/autocomplete-svelte

v1.0.0

Published

Svelte wrapper for @tomickigrzegorz/autocomplete

Readme

@tomickigrzegorz/autocomplete-svelte

Svelte wrapper for @tomickigrzegorz/autocomplete.

Installation

npm install @tomickigrzegorz/autocomplete-svelte @tomickigrzegorz/autocomplete
# or
yarn add @tomickigrzegorz/autocomplete-svelte @tomickigrzegorz/autocomplete

Usage

<script lang="ts">
  import AutocompleteInput from "@tomickigrzegorz/autocomplete-svelte";
  import "@tomickigrzegorz/autocomplete/css";

  const onSearch = async ({ currentValue }) => {
    const res = await fetch(`/api/search?q=${currentValue}`);
    return res.json();
  };

  const onResults = ({ currentValue, matches }) =>
    matches.map((el) => `<li>${el.name}</li>`).join("");

  const onSubmit = ({ object }) => {
    console.log("selected:", object);
  };
</script>

<div class="auto-search-wrapper">
  <AutocompleteInput
    {onSearch}
    {onResults}
    {onSubmit}
    placeholder="Search..."
  />
</div>

Props

All props mirror AutocompleteOptions from the core library.

| Prop | Type | Required | Description | |------|------|:--------:|-------------| | onSearch | Function | ✓ | Async search function, must return array | | onResults | Function | | Render results as HTML string | | onSubmit | Function | | Called when user selects an item | | onReset | Function | | Called when input is cleared | | onOpened | Function | | Called when dropdown opens | | onClose | Function | | Called when dropdown closes | | onRender | Function | | Called when results are rendered | | noResults | Function | | Called when no results found | | onSelectedItem | Function | | Called on each keyboard navigation | | onLoading | Function | | Called during async loading, return HTML to show a loader | | delay | number | | Debounce delay in ms (default: 500) | | howManyCharacters | number | | Min chars to trigger search (default: 1) | | clearButton | boolean | | Show clear button (default: true) | | clearButtonOnInitial | boolean | | Show clear button on initial load if input has value (default: false) | | selectFirst | boolean | | Auto-select first result (default: false) | | insertToInput | boolean | | Insert selected value into input (default: false) | | showValuesOnClick | boolean | | Show all values on input click (default: false) | | cache | boolean | | Cache results (default: false) | | inline | boolean | | Inline mode (default: false) | | disableCloseOnSelect | boolean | | Keep dropdown open after selection (default: false) | | preventScrollUp | boolean | | Preserve scroll position and highlighted item on input click (default: false) | | removeResultsWhenInputIsEmpty | boolean | | Hide results when input becomes empty (default: false) | | dropdownParent | string \| HTMLElement | | Element (or selector) to append the dropdown to — useful in modals with overflow: hidden | | dropdownAttrs | { class?: string; style?: string } | | Extra HTML attributes applied to the dropdown wrapper (when dropdownParent is set) | | regex | { expression: RegExp; replacement: string } | | Regex config used to escape special characters in the search term | | classPrefix | string | | CSS class prefix | | classGroup | string | | CSS class for grouping results | | classPreventClosing | string | | CSS class on dropdown items that should not close the dropdown on click | | ariaLabelClear | string | | ARIA label for the clear button | | placeholder | string | | Input placeholder | | class | string | | CSS class for the input element |

Updating props

Callback props (onSearch, onResults, onSubmit, …) always call the latest function passed to the component, so they can be changed at any time without re-creating the autocomplete.

Other options (delay, cache, dropdownParent, classPrefix, …) are read once on mount. To apply a new value, re-mount the component with a {#key} block:

{#key delay}
  <AutocompleteInput {delay} {onSearch} {onResults} />
{/key}

Demo

cd examples/svelte
yarn install
yarn dev

License

MIT