Limitations
What the glass cannot do, and where browsers differ.
LiquiKit bends the page with SVG filters, and browsers do not all give those filters the same reach. This page lists what that means for your interface, so you can plan around it.
Resting glass does not bend#
Glass bends the page only while it is in use: while it is pressed, dragged or focused, while a popup opens, and for a moment after. At rest it is frosted glass with its light painted on as an image. That keeps long pages full of glass smooth to scroll.
To keep a component bending all the time, set refraction="always" on it. Each one keeps a filter running while it is on screen, so use it for a few pieces rather than a whole page.
<GlassPane radius={28} refraction="always">
<div className="p-5">Now boarding</div>
</GlassPane>What the glass bends#
Only Chromium can run an SVG filter on whatever happens to be behind an element. Safari and Firefox cannot, so LiquiKit bends the content of the GlassScope you wrap around an area instead: the background you pass as backdrop, the scope's other children, and a control's own track, in every browser.
This has a few consequences:
- The filter covers the whole scope while a piece of glass in it is in use, and Safari and Firefox run it on the processor, repainting everything in the scope. Keep a scope to the area that needs it, such as a toolbar, a card or a demo stage, rather than a whole page, and around heavy artwork such as large gradients scope the control rather than the scene it sits in.
- What is outside the scope is not bent. Give the scope an opaque background, or the page behind it shows through the glass as it is.
- A video, a
backdrop-filter, or an element withwill-changeor a 3D transform inside a scope is drawn by Safari as a layer of its own, so a lens passing over it leaves it unbent, along with positioned content drawn after it that overlaps it. - Glass that overhangs the scope's edge bends up to 40px past it, the scope's
bleed, and is drawn plain beyond that. - Scopes do not nest. Put one scope around each area that needs glass.
For a large area, set refraction="backdrop" on the scope. The glass then bends a lens-sized copy of backdrop under each lens, which costs the same however large the scope is, and bends nothing else: the scope's children stay straight under a lens, a control's track is drawn straight on top of it, the backdrop is rendered twice, and a video in it plays twice and stays unbent in Safari. Give such a scope an opaque background too, or faint lines in the backdrop look doubled inside a lens.
Fixed elements inside a scope#
A GlassScope carries a CSS transform, so an element inside it with position: fixed is fixed to the scope rather than the window, and scrolls away with the page. Keep fixed headers and toolbars outside the scope.
Switches, sliders and segmented controls#
Inside a scope, these bend their own track and labels along with everything else under the lens. Outside a scope, Chromium bends the page behind them, while Safari and Firefox bend only a copy of the track and labels.
Glass on glass#
Glass that sits on other glass, such as a switch in a card or a slider in a player, bends the card under it in Chrome and Firefox, since a scope filters its whole content. Safari draws a frosted card's content as a layer of its own above the frost, where the scope's filter cannot reach it, so there such a control bends a copy of its own track instead and the card stays as it is. Both keep their frost and lit rim.
Popups#
Menus, popovers, selects and dialogs are rendered at the end of the page, outside any scope. Chromium bends the page behind them while they open. In Safari and Firefox they stay frosted glass the whole time.
The first interaction#
A component needs a set of lens maps for its shape the first time it bends. LiquiKit builds them for buttons, fields and other panes while the page is idle, so the first press is smooth. Switches, sliders and segmented controls build theirs on first use, which can cost a frame or two in a large scope.
The optics#
The refraction is physically based, not physically exact. How it works lists what the model leaves out, such as perspective and the second bend on the way out of the glass.