{"id":16791950,"url":"https://github.com/metonym/svelte-search","last_synced_at":"2025-09-11T04:41:37.965Z","repository":{"id":40672330,"uuid":"255177714","full_name":"metonym/svelte-search","owner":"metonym","description":"Accessible, customizable Svelte search component","archived":false,"fork":false,"pushed_at":"2025-01-08T00:18:35.000Z","size":401,"stargazers_count":44,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T00:08:17.531Z","etag":null,"topics":["debounce","form","input","search","svelte","svelte-component"],"latest_commit_sha":null,"homepage":"https://metonym.github.io/svelte-search/","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metonym.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T21:58:49.000Z","updated_at":"2025-01-08T00:18:39.000Z","dependencies_parsed_at":"2024-10-26T21:13:09.792Z","dependency_job_id":"9eb8adf3-6823-479a-b96f-5edbab2df725","html_url":"https://github.com/metonym/svelte-search","commit_stats":{"total_commits":55,"total_committers":6,"mean_commits":9.166666666666666,"dds":"0.12727272727272732","last_synced_commit":"7e3025eb5ea541b06bcf90f1b1c96154a582c1cb"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metonym","download_url":"https://codeload.github.com/metonym/svelte-search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419861,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debounce","form","input","search","svelte","svelte-component"],"created_at":"2024-10-13T08:43:37.103Z","updated_at":"2025-04-06T01:09:42.968Z","avatar_url":"https://github.com/metonym.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svelte-search\n\n[![NPM][npm]][npm-url]\n\n\u003e Accessible, customizable Svelte search component.\n\n\u003c!-- REPO_URL --\u003e\n\nThis search component is composed using semantic `form` and `input` elements.\n\nSee [svelte-typeahead](https://github.com/metonym/svelte-typeahead) for a search component with dropdown results.\n\nTry it in the [Svelte REPL](https://svelte.dev/playground/5e14a2cff1b9488fa4ffbff980c1f21d).\n\n---\n\n\u003c!-- TOC --\u003e\n\n## Installation\n\n\n```bash\n# npm\nnpm i svelte-search\n\n# pnpm\npnpm i svelte-search\n\n# Yarn\nyarn add svelte-search\n\n# Bun\nbun add svelte-search\n```\n\n## Styling\n\nThis component is unstyled by design. Target the component using the `[data-svelte-search]` selector.\n\n```css\n:global([data-svelte-search] input) {\n  width: 100%;\n  font-size: 1rem;\n  padding: 0.5rem;\n  margin: 0.5rem 0;\n  border: 1px solid #e0e0e0;\n  border-radius: 0.25rem;\n}\n```\n\n## Usage\n\n### Two-way binding\n\n```svelte\n\u003cscript\u003e\n  import Search from \"svelte-search\";\n\n  let value = \"\";\n\u003c/script\u003e\n\n\u003cSearch bind:value /\u003e\n\n{#if value}\n  \u003cbutton on:click={() =\u003e (value = \"\")}\u003eClear \"{value}\"\u003c/button\u003e\n{/if}\n```\n\n### on:submit\n\nThe `input` element is contained in a `form`. Use the forwarded `submit` event to obtain the value when pressing \"Enter.\"\n\n```svelte\n\u003cSearch bind:value on:submit={() =\u003e console.log(\"submit\", value)} /\u003e\n```\n\n### Label with placeholder text\n\n`$$restProps` are forwarded to the input element.\n\n```svelte\n\u003cSearch label=\"My label\" placeholder=\"Placeholder text...\" /\u003e\n```\n\n### Label slot\n\n```svelte\n\u003cSearch\u003e\n  \u003cspan slot=\"label\" style=\"color: red;\"\u003eCustom label\u003c/span\u003e\n\u003c/Search\u003e\n```\n\n### Visually hidden label\n\nSet `hideLabel` to `true` to visually hide the label.\n\n```svelte\n\u003cSearch hideLabel label=\"My label\" placeholder=\"Placeholder text...\" /\u003e\n```\n\n### Focus (declarative)\n\nUse the `autofocus` prop to declaratively focus the input.\n\n```svelte no-eval\n\u003cSearch autofocus /\u003e\n```\n\n### Focus (programmatic)\n\nBind the `ref` prop to programmatically focus the input.\n\n```svelte\n\u003cscript\u003e\n  import Search from \"svelte-search\";\n\n  let ref = null;\n\u003c/script\u003e\n\n\u003cSearch bind:ref /\u003e\n\n\u003cbutton on:click={() =\u003e ref.focus()}\u003eFocus\u003c/button\u003e\n```\n\n### Debounced input\n\nUse the `debounce` prop to specify the debounce value in milliseconds.\n\n```svelte\n\u003cscript\u003e\n  import Search from \"svelte-search\";\n\n  let events = [];\n\u003c/script\u003e\n\n\u003cSearch\n  debounce={800}\n  on:type={({ detail: value }) =\u003e (events = [...events, value])}\n/\u003e\n\n\u003cpre\u003e{JSON.stringify(events, null, 2)}\u003c/pre\u003e\n```\n\n## API\n\n`$$restProps` are forwarded to the input element.\n\n### Props\n\n| Prop name                | Type               | Default value                           |\n| :----------------------- | :----------------- | :-------------------------------------- |\n| value                    | `string`           | `\"\"`                                    |\n| label                    | `string`           | `\"Search\"`                              |\n| hideLabel                | `boolean`          | `false`                                 |\n| debounce                 | `number`           | `0`                                     |\n| ref                      | `HTMLInputElement` | `null`                                  |\n| id                       | `string`           | `\"search\" + Math.random().toString(36)` |\n| removeFormAriaAttributes | `boolean`          | `false`                                 |\n| autofocus                | `boolean`          | `false`                                 |\n\n### Forwarded events\n\n- on:input\n- on:change\n- on:submit\n- on:focus\n- on:blur\n- on:keydown\n\n### Dispatched events\n\n- **on:type**: fired when the the input value is updated\n- **on:clear**: fired when clicking the \"X\" button to clear the input value\n\n```svelte\n\u003cSearch\n  on:type={(e) =\u003e {\n    console.log(\"type\", e.detail); // input value\n  }}\n  on:clear={() =\u003e {\n    console.log(\"clear\");\n  }}\n/\u003e\n```\n\n## Changelog\n\n[Changelog](CHANGELOG.md)\n\n## License\n\n[MIT](LICENSE)\n\n[npm]: https://img.shields.io/npm/v/svelte-search.svg?color=%23ff3e00\u0026style=for-the-badge\n[npm-url]: https://npmjs.com/package/svelte-search\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetonym%2Fsvelte-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-search/lists"}