Skip to main content

CSS hooks

The script never ships a stylesheet. Everything you see is your Webflow styling — the script's only visual contribution is adding classes and data attributes you can style against.

That means two things. You can style any state without fighting specificity. And nothing changes appearance until you style it.

Classes you choose​

Two class names are configurable on the script tag, because you have probably already designed the states in Webflow.

ClassSet withApplied to
is-activedata-activeclassA selected filter item
is-hiddendata-hideclassFilter items hidden behind a "show more" control

Design a combo class in Webflow with the matching name and it will be applied automatically. If your project already uses different names, point the script at them rather than renaming your classes.

The zero-results class​

A third hook is configurable too, but per element rather than on the script tag — which is why it is not in the table above.

wf-algolia-zeroclass sets the class applied to a facet value while it has zero matching results, so you can grey it out instead of removing it. Put it on a filter group to cover its items, or on a single element.

<div
wf-algolia-element="filter-group"
wf-algolia-field="brand"
wf-algolia-zeroclass="is-empty"
>
…
</div>

The default is not uniform, so it is worth knowing which case you are in:

WhereDefault when you omit the attribute
Filter item, filter inputis-disabled
Facet count badgenone — the hook is opt-in

A count badge has no "disabled" state, so it gets no default; set the attribute explicitly if you want a badge to react to an empty facet.

A similar-looking class that this does not control

Cascading filters add is-disabled to a child group whose parent selection leaves it empty, under wf-algolia-when-parent-empty="disable". That one is a fixed internal default — wf-algolia-zeroclass does not change it. See Cascading filters.

Classes the script owns​

These are internal bookkeeping. Style them if it helps, but do not rely on them as an API — they exist so the script can find and clean up its own work.

ClassMeaning
wf-algolia-injectedAn element the script cloned from one of your templates. It removes these on the next render.
wf-algolia-focusedThe keyboard-focused item in a dropdown
wf-algolia-page-numA generated page-number control
wf-algolia-sentinelThe invisible element infinite scroll watches
Do not hand-author wf-algolia-injected

The script clears every .wf-algolia-injected element before re-rendering. Putting that class on your own markup means the script will delete it.

Data attributes on result cards​

Every rendered card carries the identity of the record it came from. These are what Insights uses for click and conversion attribution, and they are useful for your own analytics.

AttributeContains
data-wf-algolia-hit-objectidThe record's objectID
data-wf-algolia-hit-indexThe index the hit came from
data-wf-algolia-hit-queryidThe query that produced it, when click analytics are on
data-wf-algolia-hit-positionThe 1-based position in the result list
/* Style the first three results differently */
[data-wf-algolia-hit-position="1"] { … }

Reading them from your own code:

const card = event.target.closest('[data-wf-algolia-hit-objectid]');
const objectID = card?.dataset.wfAlgoliaHitObjectid;

State attributes​

AttributeMeaning
data-wf-algolia-activeThe element represents the current selection
data-wf-algolia-disabledThe control is present but cannot act yet
data-wf-algolia-stagedA selection is staged but not committed, in deferred-apply mode
data-wf-algolia-local-hiddenHidden by a client-side filter rather than by a query
data-wf-algolia-synthesizedGenerated by the script rather than cloned from your template
data-wf-algolia-overlay-resultA result rendered into an overlay surface
data-wf-algolia-hit-previewA preview card
data-wf-algolia-hrefThe resolved destination for a generated link

Styling a staged selection, for example:

[data-wf-algolia-staged] {
outline: 1px dashed currentColor;
}

Development helpers​

AttributeMeaning
data-wf-algolia-debugEnables the development linter
data-wf-algolia-issueStamped on an element the linter has flagged