26th Nov '23
/
5 comments

Opening Bricks Offcanvas with a Custom Link or Button or Div

Updated on 18 Aug 2024

Bricks comes with two elements that are typically used for setting up full-height Offcanvas sliding menus: Offcanvas and Toggle.

Toggle adds a hamburger menu icon which when clicked slides open the Offcanvas.

Sometimes you may want to trigger the Offcanvas with a text link or a Button element or a custom div.

All you need to do for that is add the class of brxe-toggle to your custom link/button.

The class can be added either in the active class input or STYLE → CSS → CSS classes.

I prefer the latter since there is no risk of accidentally generating any unwanted styling for that class.

Multiple Offcanvas elements

What if there are multiple Offcanvas elements and you want to specify which one should be toggled upon your custom text link/button/div click?

In addition to the above brxe-toggle class add a data attribute named data-selector whose value is the HTML ID or class that identifies the Offcanvas you wish to toggle.

Get access to all 610 Bricks code tutorials with BricksLabs Pro

5 comments

  • Hi there, how would you accomplish this for a navigation menu item?

  • Hi What if I have 2 offcanvas on a page? How can open a specific offcanvas?

  • when I add the class .brxe-toggle to a text-link, the offcanvas closes smoothly but the link does not take me to the corresponding page.

    • A

      I think that is the expected behavior. You want the link to either take the user to the set URL or launch a modal/offcanvas.

Leave a Reply to Igor (Cancel Reply)

 

Related Tutorials..

Pro
Mmenu Light in Bricks

Mmenu Light in Bricks

Here's the steps to implement Mmenu Light for a sliding OffCanvas mobile menu in Bricks.
Categories:
Pro
Offcanvas in Bricks using Alpine.js

Offcanvas in Bricks using Alpine.js

This Pro tutorial provides the steps to set up an offcanvas panel in Bricks using Alpine.js. Clicking on a button will slide open the panel…
Categories:
Pro
Post Content in Offcanvas using AJAX in Bricks

Post Content in Offcanvas using AJAX in Bricks

Updated on 14 Feb 2024 This Pro tutorial provides the steps to set up a list of posts whose titles which when clicked shows that…
Categories: