<pagefind-modal-trigger>

A button that opens the associated modal.

<pagefind-modal-trigger></pagefind-modal-trigger>
<pagefind-modal></pagefind-modal>

Attributes

AttributeTypeDefaultDescription
placeholderstringLanguage dependentText shown on the trigger button
shortcutstring"mod+k"Keyboard shortcut to open modal
hide-shortcutbooleanfalseHide the keyboard shortcut display
compactbooleanfalseShow only the search icon, no text
instancestring"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).

Components