A dialog search panel with live filtering, keyboard navigation, and a Ctrl or Cmd shortcut. The docs header uses this component to search every page. Press the button below, or Ctrl/Cmd + K from anywhere in the docs.
Setup
<script lang="ts">
import { Button, SearchPanel } from '.';
</script> Default
shortcut defaults to k. Pass shortcut={false} when another panel on the page already listens for that shortcut. Pass href to navigate, or onselect to run a command.
<script lang="ts">
import { Button, SearchPanel, type SearchPanelItem } from '.';
let open = $state(false);
const items: SearchPanelItem[] = [
{
id: 'accordion',
label: 'Accordion',
description: 'Components',
keywords: ['collapse', 'faq'],
href: '/docs/components/accordion'
},
{
id: 'modal',
label: 'Modal',
description: 'Components',
keywords: ['dialog'],
href: '/docs/components/modal'
},
{
id: 'input',
label: 'Input',
description: 'Forms',
href: '/docs/forms/input'
}
];
</script>
<Button onclick={() => (open = true)}>Open search panel</Button>
<SearchPanel bind:open {items} placeholder="Search components" /> Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Bindable open state |
items | SearchPanelItem[] | [] | Results. Each item needs id and label. Optional description, keywords, href, icon, onselect |
placeholder | string | Search… | Input placeholder |
emptyMessage | string | No results found. | Shown when the query matches nothing |
shortcut | string or false | k | Key used with Ctrl or Cmd. false disables it |
vim | boolean | false | j and k move the highlight |