A search input with an optional delay for value changes.
1,000 of 1,000 people
| Name | Department | Country | Status | |
|---|---|---|---|---|
| Rasmus Lovelace | rasmus.lovelace@example.com | Engineering | UK | Inactive |
| Larry Eich | larry.eich@example.com | Sales | JP | Pending |
| Joe Goldberg | joe.goldberg@example.com | Sales | JP | Inactive |
| Donald Knuth | donald.knuth@example.com | Engineering | IN | Pending |
| Ken Wirth | ken.wirth@example.com | Product | IN | Pending |
| Niklaus Stroustrup | niklaus.stroustrup@example.com | Support | DE | Pending |
| Erik Wirth | erik.wirth@example.com | Product | IN | Active |
| Anders Hejlsberg | anders.hejlsberg@example.com | Product | UK | Active |
| Bjarne Eich | bjarne.eich@example.com | Sales | DE | Pending |
| Grace Berners-Lee | grace.bernerslee@example.com | Engineering | JP | Active |
Installation
Copy the Source Code
Copy and paste the following code into your project:
table/debounce-input/debounce-input.svelte
table/debounce-input/index.ts
Folder Structure
Folder Structure
Usage
Use bind:value for controlled state or handle the debounced value with onChange.
usage.svelte
Notes
Updates are immediate by default. Set a positive delay, such as debounce={300}, to debounce them.
- The visible input always responds immediately. With a positive delay, only value and onChange wait.
- The clear button uses the same configured delay as typed input, keeping search and filter updates consistent.
Props
Debounce input props
| Name | Type | Default | Description |
|---|---|---|---|
value | string | "" | The controlled value, updated after the debounce delay. |
onChange | (value: string) => void | undefined | Called with the value after the debounce delay. |
class | string | undefined | Optional classes for the root input group. |
placeholder | string | "Search..." | Placeholder text for the input. |
debounce | number | 0 | Delay in milliseconds before updating value and calling onChange. Use a positive value to debounce updates. |