Global search
VdGlobalSearch is a site-wide command palette: glass overlay, grouped results, and keyboard navigation. Pass a GlobalSearchAdapter — the component stays engine-agnostic (Fuse.js, REST, or in-memory). These docs use Fuse over search-index.json (no semantic model).
Live demo
Press ⌘K or / (when focus is not in an input). AI toggle uses a demo adapter — no model download.
Mechanics
| Shortcut | Action |
|---|---|
| ⌘K / Ctrl+K | Open palette |
| / | Open (when not typing in a field) |
| ↑ ↓ | Move selection (wraps) |
| ↵ | Select highlighted hit |
| esc | Close and clear query |
vd:open-search | CustomEvent — e.g. dock brand |
When co-mounting VdDocSearch, set :keyboard-shortcut="false" on the inline combobox so only the global palette owns Cmd/Ctrl+K.
Props
| Prop | Notes |
|---|---|
adapter | Required GlobalSearchAdapter — async search(query, { ai }). |
shortcut | true | { key, slash } — Cmd/Ctrl+K and / (default both on). |
showAiToggle | Show AI opt-in switch + disclaimer slot (default true). |
ai | { enabled?, defaultEnabled?, persistKey? } — AI preference. |
progressMessage | Footer status while semantic model loads. |
placeholder / dialogLabel / inputLabel | Copy and ARIA labels. |
resultsLabel / hintText / searchingText / aiToggleLabel | Custom copy for the results landmark, footer hint, loading status, and AI switch label. |
openEventName | CustomEvent name to open (default vd:open-search). |
Emits & slots
| Emit | Notes |
|---|---|
select | User chose a hit (click or Enter). |
search | Debounced search settled with query + hits. |
update:aiEnabled | AI toggle changed. |
open / close | Modal visibility. |
#ai-notice — override EU AI Act disclaimer copy.
useGlobalSearch
| Option / return | Notes |
|---|---|
adapter | Same GlobalSearchAdapter as the component. |
minQueryLength / debounceMs | Defaults 2 and 350. |
shortcut | Global keydown registration (onMounted). |
ai.persistKey | localStorage key for { aiEnabled }. |
groupBy | Optional (hit) => categoryPath string. |
open / close / move / setAiEnabled | Modal control. |
highlight(text) | Returns safe HTML with <mark> for query. |
CSS custom properties
| Variable | Default | Notes |
|---|---|---|
--vd-global-search-modal-max-width | 640px | Palette width cap. |
--vd-global-search-modal-top | 15vh | Vertical offset on desktop. |
--vd-global-search-modal-border | 2px solid primary (none in dark) | Outer modal outline. |
--vd-global-search-input-border | 2px solid primary (1px in dark) | Search field outline. |
--vd-global-search-glass-opacity | 0.9 | Modal glass fill. |
--vd-global-search-glass-blur | 20px | Backdrop blur strength. |
Accessibility
- Dialog:
role="dialog",aria-modal="true". - Listbox renders only when results exist — avoids empty listbox axe violations.
- Options use
role="option"+aria-selected. - AI toggle links to disclaimer via
aria-describedbywhen enabled. - Model progress uses
aria-live="polite"in the footer.