Glass Fracture Interaction — CSS Glassmorphism & SVG Animation with Source Code
The Glass Fracture Card is a sophisticated interaction that mimics the physics of a breaking glass pane. It features high-end glassmorphism with refraction and a procedural SVG fracture pattern triggered on click.
How It Works
This effect pushes the boundaries of modern CSS and SVG integration. It uses backdrop-filter for the blurred refraction look and combines it with a dynamic JavaScript-generated SVG pattern. When clicked, the code calculates 15 random paths from the point of impact, creating a unique “crack” every single time.
Key Features
- Procedural Fracturing: No two breaks are the same thanks to a random SVG path generator.
- Realistic Refraction: Uses
backdrop-filter: blur(20px) saturate(180%)for a premium glass look. - Tilt Physics: Responds to cursor movement with a 3D tilt effect for added depth.
- Impact Shock: A subtle “shake” animation on click reinforces the physical impact of the break.
Frequently Asked Questions
Can I use this for a whole page background?
While possible, it’s best suited for interactive cards or layout elements. For a larger surface, you might need to increase the number of SVG paths for a more detailed break.
Does it work on mobile?
Yes, but the hover tilt effect only works on desktop cursors. Mobile users will still see the “break” animation on tap.
How do I “reset” the glass?
The current implementation resets the glass if you click it again while it’s in the broken state, making it a togglable interaction.