Breakpoints ❺

Detect Webflow breakpoint changes, in code

Overview

Webflow has 7 distinct breakpoints that act as the center of its responsive design methodology throughout the designer and in its published sites.

Not only are all styles tied to breakpoints, but interactions can be as well.

But what about your custom code?

Now, there's a way to do that too.

Use Cases

  • Manipulate DOM or UX aspects that are beyond the capabilities of pure CSS or styles.

  • A great example of this is our responsive pagination example that uses our breakpoints library with custom code to update Finsweet's CMS Load APIs.

  • Reload an IFRAME or other element that cannot adapt responsively across breakpoint changes.

Demonstration

On sygnal.com;

  • Press F2 to access the user-specific homepage ( for logged in users only )

  • CTRL+P Takes you to search results

Usage Notes

When you include this library in your site or page, you can easily add a custom code callback to handle events when the breakpoints change.

Here's what that would look like;

<script>
window.sa5 = window.sa5 || [];
window.sa5.push(['breakpointChanged', 
  (name, breakpoint) => {
    console.log("BREAKPOINT", name); 
  }]);
</script>

In this example, we register a breakpoint handler that is fired on the page's first load, and any time the breakpoint changes.

It will always contain one of the following values;

  • large1920

  • large1440

  • large1280

  • desktop

  • tablet

  • mobileLandscape

  • mobilePortrait

Based on the value you get, you can perform whatever scripting you like.

Getting Started ( NOCODE )

STEP 1 - Add the Library

First, add the library as detailed in Quick Start.

STEP 2 - Implement your callback handlers

See above for details.

Future

  • We may add special registration methods that perform simple tasks without code, such as navigation

Resources

Last updated