Keyword search
A search box that filters one CMS list - relevance-ranked over the whole collection, not just the rows Webflow rendered.
Shared setup - the script tag, list keys, templates, and data binding - is in the getting started guide.
For a search box over the whole site (every collection + static pages), use a global search block instead - it's the same
data-slater-search attribute pointed at a data-slater-search-list wrapper.Minimal setup
One attribute. Point a text input at the list's key:
<input type="text" data-slater-search="blog" placeholder="Search…" />| Attribute | On | Value | Required |
|---|---|---|---|
data-slater-search | <input> | the list key | yes |
Optional attributes
| Attribute | On | Purpose |
|---|---|---|
data-slater-for="<key>" | the input | Binds the input to a list when it isn't nested inside the list wrapper (needed only when the page has more than one list/search block). |
data-slater-clear="<key>" | a <button> | Resets the search box and every filter. |
Restricting which fields are searched
By default a query matches every field - name, slug, and the whole stored item, including body copy. So searching "commerce" also returns posts whose article text merely mentions the word.
Put data-slater-search-fields on the list wrapper (not the input) to scope it:
<div data-slater-list="blog"
data-slater-collection="blog"
data-slater-search-fields="titre">
…
</div>| Value | Effect |
|---|---|
| (absent) | Search everything - name, slug, every field, body copy. |
titre | Only that field. |
titre,chapo | Either field, and a titre hit ranks above a chapo hit - order matters. |
- Field slugs are the same ones you bind with;
nameandslugare valid. - An unknown slug is dropped with a console warning. If none survive, the search falls back to searching everything rather than showing an empty list.
- Scoping applies to facet counts too, so they keep describing what's on screen.
- On the raw API this is
?q=…&searchFields=titre,chapo. - Performance: the unscoped search is served by a trigram index; a scoped one is a filtered scan of that collection's rows. Fine for typical collections, measurably slower on very large ones.
Not available on a global search block - it spans collections that share no field schema. Setting it there logs a console warning and is ignored.
Behavior
- Searches the item's text (name, slug, and body fields) unless
data-slater-search-fieldsnarrows it, relevance-ranked, across the whole collection. - Debounced (300 ms) and cancels the in-flight request - typing fast fires one request, not one per keystroke.
- Resets to the first page on each change; combines with filters (AND).
- The query is sent as the
qparam; it is not reflected in the page URL.