Skip to content

Interactions

Interactions, available since Bricks 1.6, let you run an action when something happens on the front end. A simple interaction can show a hidden element on click. A more advanced interaction can listen for a query AJAX event, check browser storage, fetch an AJAX popup with the right post context, or call a custom JavaScript function.

An interaction has three main parts:

  • Trigger: the event Bricks listens for, such as click, content loaded, scroll, enter viewport, form success, or query AJAX end.
  • Action: the behavior Bricks runs, such as show, hide, toggle a class, scroll to an element, open a popup, load more results, or run a JavaScript function.
  • Target: the element affected by the action. Depending on the action, the target can be the same element, a CSS selector, or a popup template.

When editing an element, click the “Interactions” toggle icon in the panel header to open or close the element interactions interface.

If an element has interactions, the same icon appears in the structure panel. Click the icon to open that element’s interactions.

Click the ”+” icon next to the “Interactions” title to add an interaction. You can add multiple interactions to the same element. Clicking the title of a specific interaction lets you rename it.

Each interaction receives its own ID. Bricks uses this ID internally, and you can copy it when another interaction needs to listen for a specific animation-end event.

The Trigger determines when the interaction runs.

Element triggers listen on the source element:

Hover listens for the browser’s mouseover event, which fires again each time the pointer moves onto a child element. Mouse enter fires once when the pointer enters the element. Use Mouse enter with Mouse leave when an interaction should run once per visit, such as showing and hiding a tooltip.

Click interactions call event.preventDefault() by default. Since Bricks 2.0, you can enable Disable: preventDefault for a click interaction if the clicked element should keep its normal browser behavior, such as following a link.

Enter viewport and Leave viewport watch the interaction’s source element. Since Bricks 2.4, both triggers include Element visibility, which sets how much of that element must cross the viewport boundary:

  • 0%: Enter viewport runs when any part of the element becomes visible. Leave viewport runs when the element is no longer visible.
  • 50%: Enter viewport runs when half of the element is visible. Leave viewport runs after the element has reached that amount and its visible area drops below half.
  • 100%: Enter viewport runs when the whole element is visible. Leave viewport runs when it is no longer fully visible.

The default is 0%. Values between 0 and 100 are supported.

An element must fit inside the active viewport area to reach 100%. Use a lower value for elements that are taller or wider than that area.

Enter viewport also supports Root margin since Bricks 2.0. Root margin changes the active viewport boundary, while Element visibility controls how much of the source element must cross that boundary. For example, a bottom root margin of 0px 0px -50% 0px moves the lower boundary to the middle of the viewport. Leave viewport does not use Root margin.

Enter viewport interaction with Element visibility set to 50% and the Root margin field visible.

The source element remains the element that Bricks observes. To animate or modify another element when the source crosses the boundary, choose CSS selector as the interaction target and enter that element’s selector.

Browser/window triggers are not tied to a single element event:

  • Scroll
  • Content loaded
  • Mouse leave window

The scroll trigger accepts a scroll offset. Bricks supports pixel values, percentage values based on the document height, and vh values based on the viewport height. Content loaded accepts a delay such as 500ms or 1s.

The Run only once control is available for most triggers, but not for Content loaded.

When Query Filters are enabled, Bricks adds:

  • Filter: Empty
  • Filter: Not empty

These triggers listen for a specific filter element ID. You can enter the raw Bricks ID, #id, or #brxe-id; Bricks normalizes it before comparing.

Supported filter types are:

  • Active filters
  • Checkbox
  • Datepicker
  • Radio
  • Range
  • Search
  • Select

For Active filters, Checkbox, Radio, and Select, Bricks checks whether options or values are available. Select excludes the placeholder option, and Checkbox/Radio exclude the “All” option. For Datepicker and Search, Bricks checks whether the current value is empty. For Range, Bricks checks whether the selected range differs from the filter’s min/max values.

When WooCommerce is active, Bricks adds WooCommerce interaction triggers:

  • Added to cart
  • Adding to cart
  • Removed from cart
  • Bricks cart contents changed
  • Cart updated
  • Coupon applied
  • Coupon error (since Bricks 2.5)
  • Coupon removed
  • Bricks dynamic fragments refreshed
  • Bricks checkout step changed

The classic WooCommerce triggers listen for WooCommerce frontend jQuery events. Bricks cart contents changed, Bricks dynamic fragments refreshed, and Bricks checkout step changed listen for Bricks custom events and are available since Bricks 2.4.

Since Bricks 2.5, Coupon error runs when a coupon application fails on the cart or checkout. Use it to open a popup or run another interaction action. A successful application does not run this trigger.

To display the returned error in a popup:

First enable the WooCommerce Notice element under Bricks > Settings > WooCommerce. This replaces native WooCommerce notices, so follow that guide to place notices wherever your store needs them.

  1. Create a popup containing a WooCommerce Notice element and a close button. Keep AJAX loading disabled for this popup.
  2. Set the popup’s template conditions so it is available on the cart or checkout page.
  3. On an element rendered on that page, add an interaction with Trigger: Coupon error, Action: Show element, and Target: Popup. Select your popup.
  4. Save and test an invalid coupon on the frontend. For the Cart coupon element, enable its AJAX behavior.

Coupon error interaction configured with the Show element action, Popup target, and a selected popup.

The Notice element displays WooCommerce’s returned message, such as an invalid or already-applied coupon. The trigger does not provide a text placeholder for inserting the error into an ordinary Text element, or separate triggers for individual failure reasons.

Leave Run only once disabled if the popup should open after every failed attempt. Test a second failure after closing the popup to check both the message and reopening behavior.

Use Bricks cart contents changed to show a custom notice or popup after a successful AJAX addition, removal, or quantity change. It covers cart, Checkout v2, mini-cart, and Cart contents loop updates handled by Bricks and WooCommerce, including loops inside Dynamic fragments.

The trigger runs after the server confirms an item change and the related cart, checkout, and fragment updates finish. A change that needs several refresh requests produces one notification. Separate confirmed changes each produce a notification, even when their refreshes are combined.

It does not run for:

  • Initial page loading or synchronization of cached cart content.
  • Submitting a quantity without changing its value.
  • Failed requests or failed related UI refreshes.
  • Coupon, shipping, address, or totals-only recalculations.

WooCommerce must be active. This trigger does not require Enable advanced modular elements or a Dynamic fragment on the page. It listens for supported AJAX cart updates, so a normal page reload or a custom third-party cart request is not a guaranteed trigger.

Choose the trigger that matches the behavior you need:

TriggerWhen to use it
Bricks cart contents changedShow a confirmation after an item is added, removed, or its quantity changes successfully.
Added to cartRespond only to an AJAX addition, such as toggling a mini-cart Offcanvas.
Cart updatedRespond to WooCommerce’s updated_cart_totals event. This is not a general confirmation of every cart item change, particularly in checkout.
Bricks dynamic fragments refreshedRun an action after Dynamic fragment content is replaced. This can also happen on initial synchronization or checkout recalculation without an item change.

To show a “Cart updated” popup:

  1. Create a popup template containing your confirmation message and a close control.
  2. On an element that renders on the relevant pages, open Interactions and add an interaction.
  3. Set Trigger to Bricks cart contents changed.
  4. Set Action to Show element and Target to Popup, then select your popup template.
  5. Leave Run only once disabled if the popup should appear after each confirmed change.

Test on the frontend by adding an item, changing its quantity, and removing it. Close the popup between changes. Reload the page or change only a checkout address to confirm the popup stays closed.

The Action is what Bricks runs after the trigger passes any conditions.

Available actions:

Show and Hide can target regular elements or popup templates. For regular elements, Bricks changes the inline display style. For popups, Bricks calls the popup open/close logic.

Show element removes an inline display: none. If the element is still hidden after that, for example by a class, Bricks sets display: block. A flex or grid element then loses its layout. In that case, toggle a class with Toggle attribute (key class) and set the hidden and visible states in that class instead.

Set, Remove, and Toggle attribute work on the selected target. If the attribute key is class, Bricks adds, removes, or toggles class names via classList; otherwise it sets or removes the attribute itself.

The Click element action calls .click() on each target element. This is useful when you want one UI control to trigger another existing control.

The Clear form action clears inputs, textareas, selects, checkboxes, radios, and visible file results. Hidden inputs are not cleared. If the interaction is triggered by Form Submit, Form Success, or Form Error, Bricks clears the matching form. Otherwise, you can provide a target form selector; if no selector is provided, Bricks clears all forms on the page.

Map actions are available since Bricks 2.0. Use Open address (Map) and Close address (Map) when working with Map/Info Box popups and address interactions. Starting with Bricks 2.5, these actions also support Map (Leaflet).

To load more listing items and update their map markers, target the results loop containing Map Connectors with Load more (Query loop), then select that loop under the map’s Sync with query setting.

Most actions use one of these target modes:

  • Self: run on the source element.
  • CSS selector: run on every element matching the selector.
  • Popup: run on a selected popup template.

For target fields that accept an element selector or ID, use the copy button beside the field, then right-click the target element in the canvas or Structure panel and choose the offered copy action. Selector fields copy the element’s CSS ID with #; form and filter event fields copy its internal Bricks ID. Press Esc to leave this mode without copying.

Some actions do not use the standard target control because they have their own target field or no target at all. Examples include Load more, Browser storage, Toggle offcanvas, Map actions, and Clear form.

A CSS selector matches every element on the page that fits it. Inside a query loop, an interaction on one card with the selector .save-button changes the button on every card. Use Self when the change belongs to the element that was clicked: each loop item then keeps its own state. On the front end, elements inside a query loop don’t get their automatic #brxe- ID unless you set a CSS ID yourself, so a copied CSS ID matches nothing there. Target loop elements by class instead.

When a popup interaction is inside a query loop, Bricks first tries to match the popup by both the selected popup template ID and the current loop item ID. If no loop-specific popup is found, it falls back to the popup template ID.

Enable Run only once when the interaction should only run one time during the current page lifecycle. For normal element events, Bricks uses a one-time event listener. For document-level events such as form, AJAX, popup, filter, or WooCommerce events, Bricks tracks and removes the interaction after it runs.

Run only once is page-local. It is not stored across page loads. Use Browser storage actions and interaction conditions if you need a persistent or session-based rule.

Since Bricks 2.5, Slider playback controls autoplay and auto scroll on a Slider (nestable). Set Playback to Pause, Resume, or Toggle (the default).

For example, to pause a row of reviews from a separate button:

  1. Add a Button and set its HTML tag to button. Give it a label such as “Pause reviews”.
  2. Add an interaction with Trigger → Click and Action → Slider playback.
  3. Set Playback to Pause.
  4. Set Target to CSS selector and copy the slider’s CSS selector into the field.

A Button interaction configured to pause the review slider using its CSS selector.

Add a second button with Playback → Resume if visitors need a separate way to start movement again. Toggle switches between paused and playing. The interaction does not update a custom button’s text; the slider’s native Playback control provides changing Pause/Play labels.

Test on the frontend. Autoplay and auto scroll remain stationary in the Builder, and playback stays off for visitors who request reduced motion.

Use Copy to clipboard to let visitors copy a coupon code, address, link, or other text. Add an interaction to a Button or another clickable element, set Trigger to Click, and choose Copy to clipboard as the action.

The Source control has two options:

SourceWhat gets copied
Custom text (default)The content of the Text field, including dynamic data.
Element textThe text of the first element matching Target selector. Leave the selector empty to copy the text of the element that owns the interaction.

For example, enter SAVE20 as Custom text to copy a coupon code. In a post query loop, enter {post_url} to copy the clicked item’s URL. Dynamic copy text is resolved for each rendered query item, including when the interaction comes from a global class.

Element text is read when the action runs. It includes descendant text, but not HTML tags. It does not read an input’s current value or a link’s href; use Custom text with dynamic data to copy a URL that differs from the link label.

Target selector searches the whole page and uses only the first match. A shared class inside a query loop does not automatically select the clicked item’s content. Use dynamic Custom text for item-specific values, or leave the selector empty when the interaction’s own element contains the text to copy.

Test copying on the frontend over HTTPS and use a direct visitor click. The browser must support and allow clipboard writing. If clipboard access is unavailable or denied, or an Element text selector is invalid or matches nothing, Bricks runs Copy failed.

Add result interactions to the same element that owns the Copy to clipboard action:

  • Copy successful runs after the browser confirms that the text was copied.
  • Copy failed runs when copying fails.

Use these triggers to show a message, update text, or open a popup. A separate Click interaction that displays “Copied” can run before copying finishes, so use Copy successful for confirmation feedback.

Bricks does not add a notification automatically. Leave Run only once disabled if the feedback should update after each copy attempt.

  1. Add a Button labeled “Copy coupon” and a Basic Text element for the result message. Give the message element the CSS ID copy-status.
  2. Keep the message element visible and add the custom attribute role with the value status so assistive technology can announce text changes.
  3. On the Button, add Click → Copy to clipboard, select Custom text, and enter SAVE20.
  4. Add another interaction to the Button: Copy successful → Set text. Enter Copied: %copyText%, choose CSS selector as the target, and enter #copy-status.
  5. Add Copy failed → Set text, targeting the same message element, with the text “Could not copy. Select the coupon code and copy it manually.” Keep the coupon code visible on the page for this fallback.

Preview the page, click the Button, and paste into a text field to check the copied value. The result message should change only after the copy attempt finishes.

Since Bricks 2.5, Set text replaces the target element’s contents with the value of its Text field. Use Self to update the interaction’s own element or CSS selector to update matching elements.

Text is inserted as plain text. HTML markup is displayed literally, and existing child elements are removed. Target a dedicated message element rather than a container holding buttons, icons, or other content.

With Copy successful or Copy failed, %copyText% inserts the copied or attempted text. It becomes empty if copying failed before the source text could be read. With other triggers, %copyText% remains literal text.

Use Scroll to to move the page to the target element. The action supports:

  • Offset (px): subtracts pixels from the target position.
  • Delay (ms): waits before scrolling. Bricks uses a small delay by default so the DOM can update first.

In this example, after the “Posts Query” AJAX call finishes, the page scrolls to the element with the CSS selector #my-grid-wrapper, waiting 500 milliseconds first.

The Checkout step action is available for WooCommerce Checkout v2 multistep layouts.

It can move the checkout flow to:

  • Next step
  • Previous step
  • A specific step
  • A specific checkout field

Enable Scroll into view when the action should scroll the target step or field into view after the step changes.

Checkout v2 also adds the Bricks checkout step changed trigger, which runs after the active checkout step changes. See Checkout v2 multistep checkout for the full setup workflow and WooCommerce v2 query loops and dynamic tags for the related WooCommerce events.

Since Bricks 1.11, interactions can toggle an Offcanvas element from any element. Set the action to Toggle offcanvas and provide the Offcanvas CSS selector, such as #brxe-off123.

Do not apply this action directly to the Toggle element itself.

Browser storage actions let an interaction write, remove, or count a key:

  • Window storage: stored on window; resets on page load.
  • Session storage: stored in sessionStorage; normally resets when the browser tab/session ends.
  • Local storage: stored in localStorage; persists until cleared.

The storage actions use the same Key field as attribute actions:

  • Browser storage: Add writes the configured value to the key.
  • Browser storage: Remove removes the key.
  • Browser storage: Count reads the key as a number, defaults to 0, increments it by one, and stores the result.

Storage is especially useful with interaction conditions. For example, one interaction can count how many times a button was clicked, while another interaction only runs when that count is greater than 2.

Interaction fields accept dynamic data, so a key can be unique per post, for example saved-{post_id} on a button inside a query loop.

Example: Remember a saved state after reload

Section titled “Example: Remember a saved state after reload”

A save button on each card of a query loop can keep its state in the visitor’s browser. Write the saved look as CSS for a class such as is-saved (for example, a filled icon), then add four interactions to the button:

  1. Click, Toggle attribute, key class, value is-saved, target Self. This switches the look.
  2. Click, Browser storage: Count, type Local storage, key saved-{post_id}. The first click stores 1, the second click 2.
  3. Click, Browser storage: Remove, type Local storage, key saved-{post_id}, with the condition Local storage saved-{post_id} >= 2. The second click removes the key again, so the next click starts at 1.
  4. Content loaded, Set attribute, key class, value is-saved, target Self, with the condition Local storage saved-{post_id} Exists. This marks the saved buttons again after a reload.

Keep the interactions in this order. Interactions on the same trigger run one after another, and each condition is checked when its interaction runs. Two interactions that add and remove the same key on one click would undo each other.

The saved state is stored in the visitor’s browser, not in a user account. It is not shared between browsers or devices.

Since Bricks 1.9.5, interactions can execute your own JavaScript functions.

Define your functions globally:

<script>
window.myHelperFunctions = {}
myHelperFunctions.myCall = () => {
console.log('myCall executed')
}
myHelperFunctions.nestedFn = {
fn1: () => {
console.log('fn1 executed')
},
fn2: () => {
console.log('fn2 executed')
}
}
function toggleMiniCart() {
const run = () => {
document.querySelector('.bricks-woo-toggle').dispatchEvent(new Event('click'))
}
setTimeout(run, 100)
}
</script>

Enter the function name in the Function name (JavaScript) field without parentheses and without window.:

  • myHelperFunctions.myCall
  • myHelperFunctions.nestedFn.fn1
  • myHelperFunctions.nestedFn.fn2
  • toggleMiniCart

You cannot execute run() from the example above because it is scoped inside toggleMiniCart(), not on window.

Use the Arguments repeater to pass values to your function. The %brx% placeholder passes a Bricks object with interaction context:

  • source: the source element that triggered the interaction.
  • targets: the array of resolved target elements.
  • target: the current target element for this function call.

function playOrPauseVideo(brxParam, postId) {
const target = brxParam?.target || false
if (!target) {
return
}
const video = target.querySelector('video')
if (!video || !video.play || !video.pause) {
return
}
if (video.paused) {
video.play()
} else {
video.pause()
}
}

Interaction conditions let an interaction run only when browser storage matches your rules. Conditions support:

  • Window storage
  • Session storage
  • Local storage

Each condition checks a storage key with one of these comparisons:

  • Exists
  • Not exists
  • ==
  • !=
  • >=
  • <=
  • >
  • <

For numeric comparisons, Bricks converts the stored value and comparison value to numbers. Non-numeric values become 0 for those comparisons.

The Relation setting controls whether all conditions must pass or whether any condition can pass:

  • And: every condition must be true.
  • Or: at least one condition must be true.

The example above runs when window.some_key equals some_value.

Bricks uses Animate.css for interaction animations.

Set action to Start animation and choose an animation type, duration, and optional delay.

Since Bricks 2.5, Animation repetitions controls how many times the animation plays. Leave it empty for one play, or enter a positive whole number such as 3 for three plays. Enter -1 or infinite for continuous playback.

A finite animation runs Animation end after its final repetition. An infinite animation never reaches that event. Use a finite value when another interaction depends on completion, or when an exit animation must finish before a popup closes.

When the target is a popup, Bricks applies the animation to .brx-popup-content. If the animation name includes In, Bricks opens the popup. If a popup content animation includes Out, Bricks closes the popup after the animation ends.

Popups handle open and close animations directly. To open or close a popup after an animation, set the interaction action to Start animation and choose an animation ending in In or Out.

You do not need a second interaction that listens for the animation-end trigger only to open or close the popup.

Since Bricks 1.8.4, Animation end can run another interaction after a Start animation action finishes.

Use Target interaction ID to listen for a specific Start animation interaction. If you leave it empty, Bricks looks for the previous Start animation interaction in the same interaction group.

If the target ID points to the current interaction, or to an interaction that is not a Start animation action, Bricks ignores it.

In this example, interaction uzfgcm runs after the xyyyeh animation ends.

You can also listen for the same JavaScript event:

document.addEventListener('bricks/animation/end/xyyyeh', (event) => {
const element = event.detail.el || false
if (!element) {
return
}
// Your logic here
})

Query AJAX loader triggers were introduced in Bricks 1.9. They listen to Bricks AJAX start/end events for a selected query ID.

Use Query AJAX loader (Start) to run an action before a query AJAX request starts, and Query AJAX loader (End) to run an action after it completes.

Use the Filter Submit triggers for AJAX submissions from a Filter - Submit element or an Enter-key search with Trigger Filter Submit interactions enabled.

Example: Apply opacity during AJAX loading
Section titled “Example: Apply opacity during AJAX loading”
  1. Create a grid layout for your query loop and add a custom class that sets opacity to 0.5.
  2. Add one interaction to apply the class when AJAX starts.
  3. Add another interaction to remove the class when AJAX ends.

You can also listen to the underlying JavaScript events:

document.addEventListener('bricks/ajax/start', (event) => {
const queryId = event.detail.queryId || false
if (!queryId) {
return
}
// Your logic here
})

Filter Submit triggers were introduced in Bricks 2.4. They listen to AJAX submissions from the Filter - Submit element for a selected query ID. They also run when a visitor presses Enter in a Filter - Search element with Trigger Filter Submit interactions enabled. Ordinary typing does not run these triggers.

  • Filter Submit (Start) runs after Bricks updates the selected filter values and before the AJAX filter request starts.
  • Filter Submit (End) runs after the AJAX filter request finishes.

Select the target query in the Query control. Bricks only runs the interaction when the event’s queryId matches that selected query.

These triggers are useful when filters are placed inside an Offcanvas on mobile. Add a Filter Submit (End) interaction that closes the Offcanvas, and it will run after the submitted filter results have finished loading. Use Filter Submit (Start) if the Offcanvas should close as soon as the visitor clicks Submit.

Filter Submit triggers only run for AJAX filter submissions that refresh the current page results. They do not run when the Submit or Search element redirects to another URL.

The underlying JavaScript events are documented in Custom JavaScript events in Bricks.

Since Bricks 1.9.2, interactions can listen to Bricks form events.

Triggers: Form Submit, Form Success, Form Error

Form Submit runs after Bricks has prepared the form data and before the AJAX form request is sent.

document.addEventListener('bricks/form/submit', (event) => {
const elementId = event.detail.elementId
const formData = event.detail.formData
console.log('Element ID:', elementId)
console.log('Form Data:', formData)
})

Form Success runs after a successful form AJAX response.

document.addEventListener('bricks/form/success', (event) => {
const elementId = event.detail.elementId
const formData = event.detail.formData
const res = event.detail.res
// Your logic here
})

Form Error runs after an error form AJAX response.

document.addEventListener('bricks/form/error', (event) => {
const elementId = event.detail.elementId
const formData = event.detail.formData
const res = event.detail.res
// Your logic here
})

When configuring a form trigger in the Interactions panel, provide the Form ID. Bricks accepts values such as abcde, #abcde, or #brxe-abcde and compares them against the form element ID.

Filter: Empty and Filter: Not Empty were introduced in Bricks 1.11 and are available when the Query Filters feature is active.

Use them to hide, show, or otherwise update UI around filter elements whose options or values become empty after the initial page load or after a query filter AJAX update.

Filter: Empty runs when:

  • Active filters have no rendered content.
  • Checkbox, Radio, or Select has no available options, excluding “All” or placeholder options.
  • Datepicker or Search has an empty current value.
  • Range is still at its min/max default.

Filter: Not Empty runs when:

  • Active filters have rendered content.
  • Checkbox, Radio, or Select has available options.
  • Datepicker or Search has a current value.
  • Range differs from its min/max default.

Example: If a Filter - Select returns no options, hide its wrapper to avoid an empty control. Add the matching Not Empty interaction to show the wrapper again when options return.

To open a newsletter popup from a footer button:

  1. Create a Popup template named “Newsletter popup”.
  2. Set the popup template conditions to the pages where the popup should be available, such as Entire website.
  3. Add a button in the footer.
  4. Add a Click interaction to the button.
  5. Set the target to Popup, select the Newsletter popup template, and use Show element.

Now the button opens that popup wherever the popup template is rendered.

Create a hidden tooltip element, such as a Div with the class .my-tooltip, near an Icon element.

Add two interactions to the Icon:

  • Hover or Mouse enter: show .my-tooltip.
  • Mouse leave: hide .my-tooltip.

The result can look like this:

You can build a custom toggle button with two Icon elements inside a Div.

Add a custom class .toggle-button to the wrapper Div and use CSS like this:

%root% .toggle-close-icon {
display: none;
}
%root%.is-open .toggle-open-icon {
display: none;
}
%root%.is-open .toggle-close-icon {
display: block;
}

Give the default icon the class .toggle-open-icon, and the active icon the class .toggle-close-icon.

Then add interactions:

  • On the default icon, add class is-open to the wrapper.
  • On the active icon, remove class is-open from the wrapper.