Call to Action Autoload
Automatically displays the Call to Action component using the page-load interaction until the visitor dismisses it.
When the visitor clicks the close button, the code saves the dismissed state in the browser. On future page loads, it hides the component and removes the autoload attribute before the page-load interaction can run.
Component Attribute
Add the following attribute to the complete Call to Action component: b-modal-target = autoload-cta or b-popover-target = autoload-cta
This identifies the component that should load automatically when no saved dismissed state exists.
Close Button Attribute
Add the following attribute to the exit button inside the component: b-autoload-cta = dismiss
When clicked, this button saves the dismissed state and prevents the component from loading again.
Standard Form Submission
When a standard form inside the Call to Action is submitted successfully, the code detects the visible success message and saves the dismissed state automatically.
No additional attribute is required for forms that display the standard success and error states.
If the form displays an error message, the dismissed state is not saved and the Call to Action can load again on a future visit.
Redirect Form Submission
Add the b-autoload-cta = redirect-form attribute to the form-content element that redirects the visitor to another page after submission.
Redirect forms do not display the standard success message before the new page loads. This attribute allows the code to save the dismissed state when a valid form submission begins.
Because the form redirects immediately, the code cannot confirm the final server response before saving the dismissed state.
Form Placement
The form and its success message must be placed inside the element using either b-modal-target = autoload-cta or b-popover-target = autoload-cta.
This allows the code to connect the form submission to the correct Call to Action component.
Interactions
The entrance and exit animations are controlled in the Interactions panel.
The page-load interaction should target b-modal-target = autoload-cta or b-popover-target = autoload-cta.
The exit button can also have a click interaction that visually closes the component. The code allows time for this animation to complete before hiding the component as a fallback.
Saved State
The dismissed state is stored in the visitor’s browser using localStorage.
Storage key:
b_cta_closed
The Call to Action component will remain hidden on future visits in the same browser unless this saved value is cleared.
Text Area Wrapper Focus Sync
Add a custom CSS style rule for the textarea wrapper focus state.
When a textarea inside form-input is-textarea-wrapper is focused, the wrapper should receive the focus styling instead of the textarea itself.
Use on form-input is-textarea-wrapper so the wrapper can detect when an inner textarea is active. Set the wrapper border-color to currentColor during focus.
This allows the focus color to follow the wrapper’s text color.
The final CSS should target: form-input is-textarea-wrapper
And apply: border-color: currentColor;