0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Site search component powered by Pagefind for fast, client-side full-text search.
Overview
The <site-search> component opens a native modal <dialog> with a search combobox, keyboard navigation and highlighted excerpts. It uses Pagefind for indexing and searching your static site content.
The component imports pagefind.js from /pagefind/ by default. When the site is served from a subpath, point data-pagefind-path at the index directory. Result URLs get the directory above it as Pagefind’s baseUrl; set data-base-url to override that.
Search is one way into a site; an index, a glossary and a sitemap are others, and they help most when a visitor doesn't know the word to type. Put links to them in a <nav data-browse> child and the dialog shows them under a “Browse instead” heading while there are no results: before a query, and when a query finds nothing. The nav never shows in the page itself. Its aria-label, if you set one, becomes the heading.
The key cap beside the input is a button: it closes the dialog, as Escape does. Below 37.5rem the dialog is a full-width sheet from the top edge, the key cap becomes a touch-sized close button, and the keyboard hints in the footer are dropped.
Every UI string has a data-label-* override, including the result count ({count} is replaced; when the index matches more than the eight results listed, data-label-count-more also gets {total}, as in “8 of 23 results”) and the status shown when the index is missing. Developers get a console hint (“run npm run search:index”); visitors only see “Search unavailable”.
French labels
12345678910111213
<site-searchlang="fr"data-label-dialog="Recherche sur le site"data-label-placeholder="Rechercher dans la documentation…"data-label-input="Rechercher"data-label-results="Résultats"data-label-searching="Recherche…"data-label-empty="Aucun résultat"data-label-count="{count} résultats"data-label-count-one="1 résultat"data-label-count-more="{count} résultats sur {total}"data-label-unavailable="Recherche indisponible"><buttondata-trigger>Rechercher</button></site-search>
Reflected state — set by open()/close() methods, not intended as initial markup
data-pagefind-path
string
/pagefind/
Directory that holds pagefind.js, resolved against the document base. Set it for subpath deploys (e.g. /my-site/pagefind/).
data-base-url
string
—
Pagefind baseUrl prefixed to result URLs. Default: the directory above data-pagefind-path ("/" for the default path).
data-label-trigger
string
Search
Accessible name of the generated icon trigger (only when no trigger button is authored)
data-label-dialog
string
Site search
Accessible name of the search dialog
data-label-placeholder
string
Search documentation...
Input placeholder
data-label-input
string
Search
Accessible name of the search input
data-label-results
string
Search results
Accessible name of the results listbox
data-label-searching
string
Searching...
Status text while a search runs
data-label-empty
string
No results found
Status text when a query matches nothing
data-label-count
string
{count} results
Status text for several results ({count} is replaced)
data-label-count-one
string
1 result
Status text for exactly one result
data-label-count-more
string
{count} of {total} results
Status text when the index matched more results than the list shows ({count} listed, {total} matched)
data-label-unavailable
string
Search unavailable
Status text when the Pagefind index cannot be loaded (the developer hint goes to the console)
data-label-error
string
Search error. Please try again.
Status text when a search throws
data-label-untitled
string
Untitled
Title shown for a result without meta.title
data-label-navigate
string
to navigate
Footer hint after the arrow keys
data-label-select
string
to select
Footer hint after Enter
data-label-close
string
to close
Footer hint after Esc
data-label-dismiss
string
Close search
Accessible name of the close button beside the input (the Esc key cap; an × on narrow screens)
data-label-browse
string
Browse instead
Heading and accessible name of the browse links when the authored <nav data-browse> has no aria-label
data-label-powered
string
Powered by
Footer credit prefix
Required Structure
Element
Required
Description
<button data-trigger>
yes
Button that opens the search dialog (generated with a search icon when absent)
<nav data-browse>
yes
Optional author-supplied links to other ways into the content (an index, a glossary, a sitemap). Shown in the dialog while there are no results; never shown in the page. Its aria-label, if set, is the heading.
The search panel is a native <dialog> opened with showModal(): it sits in the top layer and the rest of the page is inert, so focus cannot leave it for the page behind
Escape closes the dialog and returns focus to the trigger
The input is a role="combobox" with aria-controls, aria-expanded and aria-activedescendant; the results are a role="listbox" that holds only role="option" links
A separate role="status" region announces “Searching…”, the result count, “No results found” and errors
Results are real links: Cmd/Ctrl-click and middle-click open them in a new tab
Result titles render as text and excerpts keep only Pagefind’s <mark> highlights; result URLs must be same-origin http(s)