Skip to the content

Glass surface

A surface of glass put on any box by one attribute: a navigation bar, a card, a side panel.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The pane is a box of your own: its class gives its size, its padding, its position and its border-radius, which the bend follows. Do not give it a background colour, an opacity, a filter or a backdrop filter: the Embed writes its ground. Keep its padding at least as wide as the setting bevel, so the words stay clear of the bend. A parent with an opacity under 100%, a filter or a blend mode stops the pane from seeing the page behind it, and a parent set to overflow: hidden stops a sticky pane from staying in the window.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-glass-surface Goes on the box that becomes a pane of glass, a bar, a card, a panel, and takes no value: leave the value field empty. What passes behind that box is blurred and bent at its edge, and its rim catches the light. The settings below go on the same element.
    data-glass-surface-mode, data-glass-surface-ready Written by the engine on the pane: refract where the browser paints the bend, Chrome, Edge and the other Chromium browsers, blur where it does not, Safari and Firefox, and ready once it is mounted. Never written by hand; the stylesheet reads the first, and so can a rule of yours. [ Optional ]
    data-glass-surface-defs Written by the engine on the one hidden svg it adds at the end of the page, which holds a filter per pane. Never written by hand, and removed with the last pane. [ Optional ]
    data-glass-surface-drift The motion of the preview, read by the stylesheet alone and never by the engine: the pane that carries it wanders slowly around its place, so the glass always has something new to bend. Leave it out and the pane stays where its class puts it; it stops under reduced motion. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-glass-surface-tint #1e1711 Colour laid over what is seen through the glass; written on the pane as --glass-surface-tint. A dark colour makes smoked glass, which keeps light text readable over a bright photograph; a light one makes frosted white glass, for dark text. Options: any opaque CSS colour; an empty string in the settings block writes nothing and leaves the --glass-surface-tint of your stylesheet.
    data-glass-surface-rim #ffe6bd Colour of the line of light around the pane and of the glow it leaves on the glass; written as --glass-surface-rim. Options: any opaque CSS colour; an empty string leaves the --glass-surface-rim of your stylesheet.
    data-glass-surface-density 0.42 Share of the tint laid over the glass, from 0 to 1. It is what keeps the words on the pane readable.
    data-glass-surface-blur 12 Blur of what is behind the face of the pane, in px. The bevel stays clear of it, so the bend is seen sharp.
    data-glass-surface-refraction 20 How far the edge bends what is behind, in px: at the very edge the backdrop is read that far towards the inside of the pane. Only where the bend is painted, Chromium.
    data-glass-surface-bevel 16 Width of the edge that bends, in px, from the edge of the pane inwards. It never takes more than half of the smaller side.
    data-glass-surface-dispersion 0.08 How much the colours split inside the bend, from 0 to 1: red is bent a little more than green and blue a little less, as a thick edge does.
    data-glass-surface-glint 0.9 Strength of the light on the rim, from 0 to 1, of the faint line all round as of the bright spot.
    data-glass-surface-reach 260 How far the light spreads along the rim from where it is, in px. From outside the pane it is also the distance at which the pointer starts to light the nearest edge.
    data-glass-surface-light both What moves the light. Options: both, the pointer where there is one and the scroll as soon as the page scrolls; pointer; scroll; none, the light stays where the stylesheet rests it, on the top edge.

What it does

Glass surface is a site utility component for Webflow and vanilla JavaScript, with no library. Also called frosted glass navbar, liquid glass effect or refracted glass backdrop filter.

A surface of glass put on any box by one attribute: a navigation bar, a card, a side panel. What passes behind the box is blurred behind its face and, at its edge, bent, the way the polished bevel of a thick pane bends what is seen through it: a line that crosses the edge is drawn towards the inside, compressed, and its colours split a little. A line of light one pixel wide runs around the pane; it is faint at rest, brighter where a light would catch it, and that light follows the pointer, also from outside the pane, so the edge nearest to the pointer is the one that shines. Where there is no pointer, and whenever the page scrolls, the light runs along the top edge with the scroll. The bend is a chart drawn by the engine for the exact size and corner radius of the box, read by an SVG filter inside backdrop-filter. Chromium paints that; Safari and Firefox do not, and there the pane is the blur, the tint, the rim and its light, with no bend, which is also what the stylesheet gives alone before the script arrives. Nothing is added to the box: the rim and the thickness are its two pseudo-elements, the filter lives in one hidden svg for the page. Under reduced motion the light stays where the stylesheet rests it. Not a gradient blur at the edge of a zone, and not a lens that follows the cursor: a pane, with an edge. Pattern type glassmorphism, frosted glass, liquid glass, refraction, backdrop blur.

Updated

Questions

Put data-glass-surface on your navbar and take its background colour off. The glass surface blurs what passes behind the bar, lays a tint over it and draws a line of light on its rim; place the bar sticky or fixed over the page, since glass over a flat ground shows nothing.

A frosted blur only softens what is behind. The glass surface also bends it at the edge: inside data-glass-surface-bevel, 16 px by default, the page is read up to data-glass-surface-refraction, 20 px, further in, so a line that crosses the edge curves the way it does through a thick pane. data-glass-surface-dispersion splits its colours a little.

The glass surface works there without the bend. An SVG filter inside backdrop-filter is only painted by Chromium browsers, so Safari and Firefox get the blur, the tint, the rim and its light, and the engine writes data-glass-surface-mode="blur" on the pane. Setting data-glass-surface-refraction="0" shows that same fallback in Chrome.

Yes, it is part of the glass surface. The light on the rim follows the pointer from anywhere on the page, so the edge nearest to it shines, and runs along the top edge when the page scrolls or on a touch screen. data-glass-surface-light takes both, pointer, scroll or none, and data-glass-surface-reach sets how far it spreads.

With the tint of the glass surface: data-glass-surface-tint and data-glass-surface-density, 0.42 by default, a smoked glass for light words. For dark words set a light tint and a density near 0.3. data-glass-surface-blur, 12 px by default, blurs what is behind the face of the pane while its edge stays clear.