The Offcanvas widget provides a great way to display content outside the page by transitioning it into view. It can be used for anything from displaying off-screen navigation or other content to notifications.
There are plenty of reasons why the Extras’ Offcanvas widget is useful for your site. It’s built with tons of options and support any type of content.
- Custom trigger, including an animated burger icon, simple text or a custom selector so that you can open it from any element on the page.
- Any content — Enter content from a WYSWIG editor or select any Elementor template you want
- Four transitions — Reveal, Push, Overlay, Shift – with a duration option
- Anchor Navigation — The widget recognises anchor links and handles them accordingly.
- Custom selector for closing the offcanvas using any selector from inside the content of the offcanvas.
These general settings can be found under Content > Settings. They provide general options for the behaviour of the Offcanvas widget as well as access to additional features.
- Toggle Offcanvas — A button to toggle the offcanvas panel inside the editor without having to click on the trigger
- Position — The position of the panel when opened. Can be “Top“, “Right“, “Bottom” or “Left“.
- Allow Page Scroll — If enabled, the content of the page can be scrolled when the panel is open
- Animation — The animation type of the panel when it’s opened. Can be “Reveal“, “Push“, “Overlay” or “Shift“. See examples here.
- Animation Duration — How long the animation should last.
- Anchor Navigation — If enabled, the widget will look for links to anchors on the page inside the offcanvas panel and bind events to those links that scroll the page content to their respective anchors.
- Close After Scroll — Wether or not to close the offcanvas panel when the page scrolls to an anchor
- Anchor Navigation Speed — The speed at which the page content scrolls when an anchor inside the panel is clicked
The offcanvas can be triggered using the default options that let you create a button, a text link, an icon or all of the three. This is how the settings for the Trigger look like:
The “Burger” option gives you an animated burger icon with text as a trigger to open your offcanvas. These are the settings available for the burger icon trigger:
- Position — Inline or Floating.
- IMPORTANT: We don’t recommend using the Floating option, which was introduced before Elementor released Custom Positioning controls. Instead, set the Advanced > Custom Positioning > Position control to Fixed to have the trigger fixed on the screen. This does the same as Floating, but you can take advantage of the advanced positioning controls for Elementor and place it anywhere on the page instead of the strict Placement control the widget offers.
- Label — The text next to the burger icon
- Show — Hides or shows the label
- Text — The text to display
- Icon — The burger icon
- Position — relative to the label. Can be “Hide“, which hides the icon completely, “Before Label” or “After Label“.
- Animation — A number of animation options for the burger icon
- Distance — The space between the icon and the label
The “Element ID” and “Element Class” are explained below.
The offcanvas panel has a prebuilt header with a title and a close icon. The title can hidden altogether or customised using these settings:
- Content > Title
- Show — Hide or show the default title of the offcanvas panel
- Title — The title text
- Title HTML Tag — The HTML tag to be used for the title
The widget also comes with a close icon built into the offcanvas panel. This can be replaced by your own custom close icon or button within the content of the panel or, if the Elementor template you’re displaying.
- Content > Close
- Source — Where the close comes from
- Default — The built in close icon shown next to the Title.
- Element ID — An element with a specific ID within the content of the panel or the template used for the content
- Element Class — An element with a specific class within the content of the panel or the template used for the content. If you have multiple elements with the same class, clicking on any element will close the offcanvas
- Position — Available only of Source is set to Default. The position of the close icon relative to the built in title of the offcanvas panel
- Close CSS ID — Available only of Source is set to Element ID. The selector, without the # (pound character) in front, for the element found within the panel content to close the offcanvas panel when clicked.
- Close CSS Class — Available only of Source is set to Element Class. The selector, without the . (dot character) in front, for the element(s) found within the panel content to close the offcanvas panel when clicked.
- Source — Where the close comes from
You can have any element act as the trigger for opening the off-canvas panel. Under Content > Trigger > Source, select Element ID if you want to target an element by it’s ID, or Element Class if you want to target it by a class. If you choose Element Class, all elements with that class will trigger the off-canvas panel when clicked.
We’ll explain, step by step, how to make a Button widget with the ID ‘offcanvas-trigger‘ act as a trigger for opening the panel:
- Select your Button widget
- Under Content > Button ID type in offcanvas-trigger. Your button how has this ID.
- Select your Offcanvas widget
- For Content > Trigger > Source select Element ID.
- An option Trigger CSS ID appears below. Enter offcanvas-trigger as the value for that control.
- Click your Button widget and your offcanvas will open.
The example above is using Element ID as a selector for the trigger source. If you want to use Element Class instead, go to your Buttons’ Advanced tab and under Advanced > CSS Classes, enter your offcanvas-trigger class.
The off-canvas panel can have different kind of content inside it. This content is handled by a repeater field so that you can select add multiple different kinds of content without having to save them into one template. For example, you can add custom content form a WYSWIG field and another template right underneath. Mixing types of content inside the panel gives you a lot of flexibility.
There are three types of content available:
- Text — this lets you add content using a WYSWIG field.
- Template — Give you access to your Elementor saved templates (sections, pages and widgets) that you can insert in the panel
- WordPress Sidebar — Add a saved WordPress Sidebar inside the panel. These are created in Appearance > Widgets in your WordPress dashboard.
When the Offcanvas panel opens, the page scroll functionality dissapears. Because of the this, some browsers hide the scrollbar, resulting in a horizontal page jump. We’ve implemented two hacks to fix this under the Content > Settings > Scroll Fix option, but each have their drawbacks. “Margin Hack” adds “margin-left: calc(100vw – 100%);” to the html element but fixed elements still jump on the page. “Overflow Fix” sets the horizontal overflow to scroll to always show the scrollbar placeholder, leaving a margin to the right of the page and, if you set the Allow Page Scroll option to Yes you will get two scrollbars (one for the page and one for the page content on which we set overflow-y to scroll. Choose the one that fits your needs by simply testing both.
Can I have the trigger be always visible on top of the overlay?
Most likely yes, but it depends on the z-indexes you are using. We suggest going to the top-most section that contains your trigger or offcanvas widget (in case the trigger Source control is set to “Burger“) and setting that section’s Z-index control to a value that is higher than 998 (which is the z-index of the page overlay).
Can I have the trigger fixed on the page, outside the panel and page content?
Unfortunately, no. Because the whole page is wrapped in the container and because all Elementor elements are within the page, this is impossible. Moreover, the page uses CSS transform, which means that even if you set the position to fixed, it will become fixed relative to the page content.
The content inside the off-canvas panel is hidden, not shown entirely or simply messed up
If that’s the case, if you’re using an Elementor template as a content box, please check to see if inside the content of the panel there is no section that has the Stretch option enabled. Dynamically stretched content should not exist since the position and properties of the panel change when the off-canvas is opened and closed.