<pagefind-modal-trigger>
A button that opens the associated modal.
<pagefind-modal-trigger></pagefind-modal-trigger>
<pagefind-modal></pagefind-modal>
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
placeholder | string | Language dependent | Text shown on the trigger button |
shortcut | string | "mod+k" | Keyboard shortcut to open modal |
hide-shortcut | boolean | false | Hide the keyboard shortcut display |
compact | boolean | false | Show only the search icon, no text |
instance | string | "default" | Connect to a specific Pagefind instance |
Keyboard Shortcut
By default, the trigger listens for Cmd+K (Mac) or Ctrl+K (Windows/Linux) to open the modal. The keyboard listener is attached at the document level, so the shortcut works from anywhere on the page.
Customizing the Shortcut
You can customize the keyboard shortcut using the shortcut attribute:
<!-- Single key (no modifier) -->
<pagefind-modal-trigger shortcut="/"></pagefind-modal-trigger>
<pagefind-modal></pagefind-modal>
<!-- With modifier -->
<pagefind-modal-trigger shortcut="mod+p"></pagefind-modal-trigger>
<pagefind-modal></pagefind-modal>
Example with / key:
Supported syntax:
- Platform modifier:
mod(Ctrl on Windows/Linux, Cmd on Mac) - Explicit modifiers:
ctrl,shift,alt,cmd/meta - Keys: Any single character (e.g.
k,/) or key name - Case-insensitive: Keys are normalized to lowercase
The shortcut display auto-detects the platform to show the correct modifier key (⌘ on Mac, Ctrl on other platforms).