Skip to content
Open in

Mobile-first email template ​

The mobileFirstEnabled option controls the editor's mobile-first tooling: a mobile and desktop canvas switch, plus per-device visibility controls on blocks and structures. It is on by default.

This is an editing aid. The generated HTML is the same either way, since responsive behavior comes from the template itself rather than from this option.

Mobile preview showcase video

Mobile-first support is enabled out of the box. To turn it off, include the following option in your TOPOL_OPTIONS configuration:

ts
mobileFirstEnabled: false; // enabled by default, set to false to disable

Switching between views via API ​

If you're using a custom top bar or custom interface instead of the default one, you can control the device preview using the Plugin's built-in methods:

ts
editor.changeEmailToMobile(); // display mobile preview

editor.changeEmailToDesktop(); // display desktop preview

Toggle visibility of hidden elements ​

Blocks and structures can be hidden per device type, so a section can appear on desktop but not on mobile. Hidden elements are recorded on the block as a CSS class: hide_on_mobile or hide_on_desktop for blocks, and hide_section_on_mobile or hide_section_on_desktop for structures.

To toggle how hidden elements are displayed on the canvas, use:

ts
editor.toggleHiddenElementsVisibility();

One state renders hidden elements at 25% opacity so they remain selectable, and the other removes them from the canvas entirely. The method flips between the two and takes no argument, so there is no way to set a specific state.

Track visibility changes ​

The editor reports every change to the hidden elements' visibility through a callback, so a custom top bar can keep its toggle in sync:

ts
const editor = TopolEmailEditor({
  config: TOPOL_OPTIONS,
  //other callbacks...

  onHiddenElementsVisibilityChange({ visible }) {
    // `visible` is true when hidden elements are shown on the canvas
  }
});

INFO

The callback fires for the Show hidden switch in the top bar, for toggleHiddenElementsVisibility(), and when the editor reveals hidden elements on its own. It does that after a device switch, through the UI or through changeEmailToMobile() and changeEmailToDesktop(), that would otherwise leave the canvas empty because every block or every structure is hidden for that device.