Skip to content
UIGlass

Tutorials

Liquid Glass in WordPress: Gutenberg, Elementor and Divi (With and Without Plugins)

Add a real liquid glass effect to any WordPress site: a small functions.php snippet for the SVG filter, a reusable CSS class for Gutenberg, Elementor and Divi, page-builder add-ons compared, and the caching settings that silently break it.

·6 min read·Tutorials

In short: To add liquid glass to WordPress without a plugin, print one SVG filter and a detection script with a small functions.php snippet, add a glass CSS class in Additional CSS, and put that class on a Gutenberg block, Elementor container or Divi module that sits over an image.

WordPress has no liquid glass setting, and you don’t need a heavy plugin to get one. The effect is CSS plus one SVG filter, and WordPress has standard places for both. This guide shows a method that works with any theme and any page builder, then compares the plugin options for people who’d rather click than paste.

The plan

  1. Print the SVG filter and a one-line detection script on every page (one PHP snippet).
  2. Add a reusable .glass class in your site’s CSS.
  3. Put that class on any block, container or module.

Step 1: add the filter and detection (functions.php or a snippet plugin)

Add this to your child theme’s functions.php, or with a code-snippets plugin. Never edit a parent theme directly, because updates overwrite it.

<?php
// Liquid glass: enable refraction only in Chromium browsers.
add_action('wp_head', function () {
    echo "<script>if (navigator.userAgentData?.brands?.some(b => b.brand === 'Chromium')) document.documentElement.classList.add('lg-refract');</script>\n";
}, 1);

// Liquid glass: the edge displacement filter, printed once per page.
add_action('wp_body_open', function () { ?>
<svg width="0" height="0" style="position:absolute" aria-hidden="true" focusable="false">
  <filter id="lens" x="0" y="0" width="1" height="1"
          primitiveUnits="objectBoundingBox" color-interpolation-filters="sRGB">
    <feImage x="0" y="0" width="1" height="1" preserveAspectRatio="none" result="map"
      href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 200' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='x'%3E%3Cstop offset='0' stop-color='rgb(64,0,0)'/%3E%3Cstop offset='1' stop-color='rgb(191,0,0)'/%3E%3C/linearGradient%3E%3ClinearGradient id='y' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='rgb(0,0,0)'/%3E%3Cstop offset='1' stop-color='rgb(0,255,0)'/%3E%3C/linearGradient%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='10'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='300' height='200' rx='28' fill='url(%23x)'/%3E%3Crect width='300' height='200' rx='28' fill='url(%23y)' style='mix-blend-mode:screen'/%3E%3Crect x='24' y='24' width='252' height='152' rx='4' fill='rgb(128,128,128)' filter='url(%23b)'/%3E%3C/svg%3E"/>
    <feDisplacementMap in="SourceGraphic" in2="map" scale="-0.18"
                       xChannelSelector="R" yChannelSelector="G"/>
  </filter>
</svg>
<?php });

wp_body_open fires right after <body> in block themes and in any modern classic theme. If your theme is very old and lacks it, use wp_footer instead. The filter works from anywhere in the page.

Step 2: add the glass class

Block themes (Twenty Twenty-Five and similar): Appearance → Editor → Styles → Additional CSS. Classic themes: Appearance → Customize → Additional CSS.

.glass {
  position: relative;
  isolation: isolate;
  border-radius: 28px;
  color: #fff;
  background: rgb(255 255 255 / .10);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .55),
    inset 0 -1px 0 rgb(255 255 255 / .12),
    0 10px 30px rgb(0 0 0 / .25);
}
.lg-refract .glass {
  -webkit-backdrop-filter: url(#lens) blur(2px) saturate(160%);
  backdrop-filter: url(#lens) blur(2px) saturate(160%);
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .lg-refract .glass {
    background: rgb(20 22 30 / .92);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

For the rim light and full explanation of each value, see the liquid glass CSS guide.

Step 3: apply it in your editor

EditorWhere to add the classTips
Gutenberg (block editor)Select a Group, Cover inner group or Buttons block → Block settings → Advanced → *Additional CSS class(es)* → glassPut the glass Group inside a Cover block with an image, so there’s something to bend
ElementorSelect a container or widget → Advanced → *CSS Classes* → glassSet the container background to none. CSS classes work in Elementor Free; the *Custom CSS* field needs Pro
DiviModule or row settings → Advanced → *CSS ID & Classes* → *CSS Class* → glassDisable the module’s own background colour
Bricks, Breakout and othersThe element’s class/attributes fieldSame idea: no background, class glass

Remember that glass needs something behind it. Over a flat white section it looks like a faint grey box. Place glass over images, video, gradients or colourful sections.

Plugin options compared

If you prefer not to touch code:

OptionWorks withRefractionPriceNotes
ElementsKit — Liquid Glass moduleElementorDistortion presets (Deep Glass, Crystal Flow, Molten Glass…)ProEnable under ElementsKit → Modules, then per section in Advanced
SilicaElementor containersGlass with light angle, frost and depth in ProFree + ProSmaller plugin, toggle in the Style tab
Essential AddonsElementorLiquid Glass Effect extensionTheir tutorial lists Pro as a requirementEnable under Extensions; their own notes list Chrome, Opera, Edge and Brave
Snippet + CSS (this guide)Any theme or builderShaped edge lens in Chromium, frosted elsewhereFreeNo extra plugin, full control
UIGlass builder exportAny theme or builderShaped lens, states, Scene modeFreeDesign visually, paste the exported CSS and SVG

Builder add-ons rarely document how they behave in Safari and Firefox, so check your site on an iPhone before launch. The Safari and Firefox guide explains what to expect.

Caching and optimisation plugins: three settings that break glass

These are the most common reasons a working effect disappears on the live site:

  1. “Delay JavaScript execution” (WP Rocket, FlyingPress, Perfmatters and similar) delays the one-line detection script until the visitor interacts, so refraction appears late or never. Exclude the script, for example by excluding the keyword lg-refract.
  2. “Remove unused CSS” scans your HTML for classes. lg-refract is added by JavaScript, so it isn’t in the HTML and the refraction rules get stripped. Add lg-refract and glass to the safelist.
  3. HTML minifiers sometimes rewrite inline SVG or data URIs. If refraction stops working after enabling minification, exclude the SVG or switch the minifier’s SVG option off.

Performance on WordPress sites

  • Keep glass on headers, cards, buttons and callouts, not on whole-page wrappers.
  • One SVG filter can serve every glass element on the page. Don’t print it per block.
  • Test on a mid-range Android phone with your real images. The performance guide covers the details.

Frequently asked questions

How do I add a liquid glass effect in WordPress without a plugin?

Add the SVG filter and detection script with a small functions.php snippet, put the .glass CSS in Additional CSS, and add the class glass to a block, container or module. All the code is above.

Does liquid glass work in Elementor Free?

Yes. Elementor Free lets you add CSS classes under Advanced → CSS Classes. Put the CSS in Appearance → Customize → Additional CSS (or your theme’s Styles). Elementor Pro is only needed for its per-widget Custom CSS field.

Why does my glass effect work in the editor but not on the live site?

Usually a caching or optimisation plugin: delayed JavaScript, “remove unused CSS” stripping the lg-refract rules, or HTML minification changing the SVG. See the three settings above.

Is there a Gutenberg block for liquid glass?

Core WordPress has none. Use a Group block with the glass class, or a plugin that adds one. A Group inside a Cover block is the easiest way to get a photo behind the glass.

Will liquid glass slow down my WordPress site?

The code is a few kilobytes and doesn’t affect loading. Rendering cost depends on how much of the screen is glass. Keep it on smaller elements and avoid stacking glass panels.

Where do I add custom CSS in WordPress?

In block themes, go to Appearance, Editor, Styles, Additional CSS. In classic themes, go to Appearance, Customize, Additional CSS.

How do I add liquid glass in Divi?

Add the CSS once in your theme’s custom CSS, then open the module or row settings, go to Advanced, CSS ID & Classes, and set the CSS class to glass. Remove the module’s own background colour.

Why is refraction missing after I enabled WP Rocket or another optimisation plugin?

Delayed JavaScript postpones the detection script, and “remove unused CSS” can strip the lg-refract rules. Exclude the script and safelist the lg-refract and glass classes.

Do I need a child theme for liquid glass?

Use a child theme or a code-snippets plugin for the PHP snippet. Changes to a parent theme’s files are lost when the theme updates.

Keep reading