diff --git a/src/components/SearchInput/SearchInput.mdx b/src/components/SearchInput/SearchInput.mdx
index cd743181..6c347cd5 100644
--- a/src/components/SearchInput/SearchInput.mdx
+++ b/src/components/SearchInput/SearchInput.mdx
@@ -12,16 +12,18 @@ The `SearchInput` component creates a search bar.
-
+
```
-
\ No newline at end of file
+
diff --git a/src/components/SearchInput/SearchInput.stories.svelte b/src/components/SearchInput/SearchInput.stories.svelte
index bca718e7..ae596d55 100644
--- a/src/components/SearchInput/SearchInput.stories.svelte
+++ b/src/components/SearchInput/SearchInput.stories.svelte
@@ -8,4 +8,17 @@
});
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/components/SearchInput/SearchInput.svelte b/src/components/SearchInput/SearchInput.svelte
index c89a83dc..01e78d05 100644
--- a/src/components/SearchInput/SearchInput.svelte
+++ b/src/components/SearchInput/SearchInput.svelte
@@ -6,15 +6,23 @@
interface Props {
/** The placeholder text that appears in the search box.*/
searchPlaceholder?: string;
+ /** Optional function that runs when the input value changes. */
+ onsearch?: (newValue: string) => void;
}
- let { searchPlaceholder = 'Search...' }: Props = $props();
+ let { searchPlaceholder = 'Search...', onsearch }: Props = $props();
let value = $state('');
let active = $derived(value !== '');
function clear() {
value = '';
+ if (onsearch) onsearch(value); // Call the prop to update the parent when cleared
+ }
+
+ function oninput(event: Event) {
+ value = (event.target as HTMLInputElement).value;
+ if (onsearch) onsearch(value); // Update the parent on every input change
}
@@ -22,12 +30,14 @@