How to use it
In Bricks > Kiln, turn on Site: breakpoint classes on the body.
Style against the class of the breakpoint you want. Kiln adds these to
<body>:kiln-bp-{key}: the active breakpoint, and only that one. For examplekiln-bp-mobile_portrait.kiln-bp-in-{key}: every breakpoint whose styles apply right now, following Bricks' own cascade. That is the base breakpoint plus each breakpoint whose media query currently matches. To style "tablet portrait and smaller", target.kiln-bp-in-tablet_portrait.data-kiln-bp="{key}": the active breakpoint as an attribute.
To react in JavaScript, listen for the
kiln:breakpointevent ondocument:document.addEventListener( 'kiln:breakpoint', function ( e ) { console.log( e.detail.previous, '->', e.detail.key ); } );
{key} is the key Bricks gives the breakpoint, such as tablet_portrait. Custom breakpoints get classes too.
Paused breakpoints are skipped.
Where it appears in Bricks
Nowhere in the builder panels. The classes are on the front end. The script does not run in the builder's main window. The builder canvas keeps it, so the classes also show while you edit.
How it works with your breakpoint setup
Kiln builds its media queries the way Bricks does. A breakpoint wider than the base uses min-width. A narrower
one uses max-width. Desktop-first sites, mobile-first sites and a base in the middle (a desktop base plus a
custom wider breakpoint) all match the CSS Bricks prints for the site.
The active breakpoint is the matching one farthest from the base.
Limits
- The classes are set by JavaScript, so the HTML sent by the server has none of them. A small inline script at the
top of
<body>sets them before the content paints. - The
kiln:breakpointevent fires when the breakpoint changes. It does not fire for the first one on page load. - The script carries the attributes
nowprocket,data-no-optimize,data-no-deferanddata-cfasync="false", which WP Rocket, LiteSpeed Cache and Cloudflare Rocket Loader read as "don't delay this script". Another optimizer that delays JavaScript, such as Perfmatters, may need the script excluded in its own settings.
Settings
None. The module is off by default, because it prints a script on every page.
Requirements
Bricks 2.4 or newer.