GlassmorphismPremium

Solid to Glass Button

A solid button that turns to glass on hover or keyboard focus: its colour fades, the blur rises to 16 px and its edges ripple for 0.6 s via an SVG filter.

JSSVGHoverMorph

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Glassmorphism has 47 effects, including 6 free. Explore the category →

3 usage examples

“Start the test” button in the middle of the page — a hearing-aid clinic's online hearing check — Solid to Glass Button example 1

① “Start the test” button in the middle of the page — a hearing-aid clinic's online hearing check

WhenA visitor lands on the test page: a heading, one sentence of explanation, and a single button in the middle, surrounded by its halo.
WhyIt is the page's only action, so it can afford a halo of colour. Solid at rest, the button reads effortlessly; when the hand comes near, it turns to glass and quivers — a response that invites the click without moving anything around it.
SettingsButton widened to 250 px (padding: 16px 0, 15 px label); original halo and colours; root with no background, set on the site's dark page.
Four answers laid over the photo — a mountain magazine's “Which summit is this?” quiz — Solid to Glass Button example 2

② Four answers laid over the photo — a mountain magazine's “Which summit is this?” quiz

WhenThe reader has to recognise a summit: the photo fills the screen and the four answers sit on top of it, at the bottom.
WhyThe answers hide part of the photo — yet the photo is what must be studied. Solid, they are readable; hovered, each becomes a pane that lets you look again at the lake and the forest behind it before choosing.
SettingsFour buttons in a single root with a single SVG filter, in a 2 × 2 grid (166 × 42 px); halo removed: the glass frosts the photo directly; the scene script rings the right answer in green after the click — the turn to glass itself comes from the script you buy.
Slideshow arrows over the photos of a bow-top wagon for rent — a farm campsite's website — Solid to Glass Button example 3

③ Slideshow arrows over the photos of a bow-top wagon for rent — a farm campsite's website

WhenA holidaymaker flicks through the wagon's three photos: two square arrows sit on the edges of the current photo.
WhyAn arrow must be found at a glance on any photo, light or dark: solid at rest, it always shows. Under the pointer it fades into glass and no longer hides the corner of the picture you are about to leave.
SettingsTwo copies of the effect, each with its own filter; 40 × 40 px buttons, 12 px corners, 30 px chevron, an aria-label each; halo removed; the scene script changes photo on click.

How it works

At rest it is an opaque button: 85% indigo, 14 px corners, 153 × 46 px with its original label. It sits on .lg-morph-btn-bg, a halo that sticks out 20 px all round and whose gradient — indigo, violet, fuchsia, pink — goes back and forth in 4 seconds. As long as nothing is touched, that halo is just a coloured frame: the button hides it.

When the pointer enters, the script adds the lg-morph-btn--glass class. In half a second the fill drops to 10% white, backdrop-filter rises from 0 to blur(16px) saturate(1.8) and a slanted sheen appears: the button changes material and shows, frosted, what it was covering. The transition curve overshoots slightly before settling — the blur reaches 16.5 px before coming back to 16. Its size does not move.

At the same moment the script applies the SVG filter shipped inside the root: feTurbulence noise pushes the button's pixels through feDisplacementMap, whose strength rises from 0 to 12 then falls back within 0.6 s. The edges buckle like a drop that has just been touched, then the filter is removed. When the pointer leaves, the class goes and the button is solid again. Each copy of the effect gets its own filter id: two buttons on a page never ripple for one another.

Accessibility

  • Keyboard: focus arriving by Tab produces the same turn to glass, ripple included, plus a 2 px white outline; the button turns solid again when it loses focus. Measured in Chromium and Firefox, and in WebKit with Option + Tab (Safari's default setting). A mouse click does not replay the ripple.
  • Reduced motion: the script reads prefers-reduced-motion on every hover. When it is on, the SVG filter is not applied — measured: filter: none throughout the hover — and the halo stops sliding. The change of material stays, since that is what signals the state.
  • Touch: there is no hover on a touch screen. Measured in Chromium and WebKit touch emulation: a tap triggers the turn to glass, and the button stays glass until you tap elsewhere. If the button changes page you hardly see it; otherwise, plan for it.
  • Contrast: white label at 4.4:1 on the solid button — just under the 4.5:1 threshold — and between 2.3:1 and 3.7:1 once in glass, when the halo's fuchsia passes behind. The text shadow helps a little; for a truly readable label, darken the glass: .lg-morph-btn--glass { background: rgba(30, 27, 75, .35) }.
  • Screen readers: nothing is announced when the material changes, on purpose — the state is decorative and the label does not change. The filter's <svg> carries aria-hidden="true".

Browser compatibility

Measured under Playwright in Chromium, Firefox and WebKit: class added and removed, ripple visible in the captures of all three engines, two independent copies, no name added to window. The frosting itself could only be looked at in Chromium: automated captures of Firefox and WebKit do not paint backdrop-filter, even on a minimal test block. Real Safari: not verified. Minimum versions per MDN: inset for the halo (Chrome 87, Edge 87, Safari 14.1), backdrop-filter (Firefox 103; -webkit- prefix declared for Safari before 18). SVG filters and beginElement() have existed far longer in those four browsers.

Chrome 87+✓ Full (measured, frosting seen)
Firefox 103+✓ States and ripple measured; frosting cannot be checked in automated captures
Safari 14.1+✓ Not verified on a real Safari (states and ripple measured in WebKit)
Edge 87+✓ Not verified (same engine as Chrome)
Mobile iOS 14.5+✓ Not verified — on tap, the button stays glass
Android Chrome 87+✓ Measured in emulation: turns to glass on tap and stays so until the next tap

Without JavaScript the button stays solid and fully usable: only the effect goes. Without the <svg> block the script finds no filter and settles for the change of material, with no error. Without backdrop-filter the glass state is a plain 10% white veil: over a busy background, give it a denser tint.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0323-root">
  <div class="lg-morph-btn-wrap">
    <div class="lg-morph-btn-bg"></div>
    <button type="button" class="lg-morph-btn" data-morph-btn>…</button>
    <svg class="lg-morph-defs" width="0" height="0" aria-hidden="true" focusable="false">
      <filter id="lgMorphDisplace">
        <feTurbulence type="fractalNoise"></feTurbulence>
        <feDisplacementMap>
          <animate attributeName="scale"></animate>
        </feDisplacementMap>
      </filter>
    </svg>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Solid colour (CSS — .lg-morph-btn { background }) rgba(99, 102, 241, .85), 20% white border Use your brand colour. Leave a little transparency (0.85 to 0.95): the fade to glass is softer than from a 100% flat fill.
Glass state (CSS — .lg-morph-btn.lg-morph-btn--glass) 10% white, blur(16px) saturate(1.8), 30% border Over a detailed photo, raise the blur to 24 px. A dark tint (rgba(30,27,75,.35)) keeps the label readable. Edit both filter lines, prefixed and unprefixed.
Length and bounce of the change (CSS — transition: .5s cubic-bezier(.34, 1.56, .64, 1)) 0.5 s, with overshoot The curve's second figure (1.56) makes the overshoot; bring it down to 1 for a fade with no bounce. Under 0.3 s the change of material feels abrupt.
Ripple strength (HTML — <animate values="0;12;0" dur="0.6s">) strength 12, 0.6 s 20 gives a frankly liquid button, 6 a shiver. If you change the duration, also change the script's 600 delay, which removes the filter at the end.
Ripple grain (HTML — <feTurbulence baseFrequency="0.012 0.035">) wide waves, a single octave Smaller values give one big wave; past 0.05 the edges bristle and the label gets hard to read during the effect.
Halo (CSS — .lg-morph-btn-bg) 20 px overhang, four colours, 4 s loop Change the gradient colours, or delete the element to set the button over your own image: the glass then frosts whatever lies behind it on the page.
Size (CSS — padding: 14px 32px, font-size: .9rem, border-radius: 14px) 153 × 46 px with the original label The button does not change size when it turns to glass: you can give it a fixed width or place it in a grid without anything shifting around it.

FAQ

They look alike but do different things. The first one is glass from the start and changes shape on hover — it stretches, rounds its corners, grows by 5% — in pure CSS, with no script. This one does not change size: it changes material, from solid to glass, with a few lines of script, an SVG ripple and its own animated halo. Pick the first for a button that is always transparent over a video; this one when the button must stay clearly readable at rest and only reveal the background when you come near.
Yes. On load the script walks through each .fx-0323-root, renames its filter (lgMorphDisplace-0, -1…) and wires every [data-morph-btn] button it contains: several buttons can therefore share one root and one <svg> block, like the four quiz answers. Two limits: the script must come after the HTML, and only the roots present at that moment are wired: for a root added later, run the script again, it skips the ones already set up; a button slipped afterwards into a root that is already wired stays inert.
Not with the original script: it removes the class as soon as the pointer leaves or focus moves away. For a lasting “selected” state, add a class of your own on click and give it the same style in the CSS — .lg-morph-btn.is-chosen next to .lg-morph-btn--glass — rather than reusing the one the script wipes. Remember aria-pressed so the state is announced too.