A lightweight, customizable solid glass effect library for modern web applications. Create Apple-like glass effects with dynamic distortion, customizable tints, and smooth animations.
π Live Demo
- π¨ Fully Customizable: Control every aspect of the glass effect
- π Lightweight: Minimal dependencies, optimized performance
- π§ Framework Agnostic: Works with vanilla JS, React, and Vue
- π Dynamic Effects: Real-time noise distortion and frost effects
npm install solid-glassOr with yarn:
yarn add solid-glassimport { SolidGlass } from "solid-glass";
import "solid-glass/style.css";
const element = document.getElementById("my-glass-element");
const glass = new SolidGlass(element, {
tintColor: "255, 255, 255",
tintOpacity: 0.05,
frostBlur: 10,
noiseFrequency: 0.01,
distortionStrength: 80,
});import { SolidGlassReact } from "solid-glass/react";
import "solid-glass/style.css";
function App() {
return (
<SolidGlassReact
width="400px"
height="300px"
tintColor="#ffffff"
tintOpacity={0.05}
frostBlur={10}
>
<h1>Your Content Here</h1>
</SolidGlassReact>
);
}<template>
<SolidGlass
:tint-color="'#ffffff'"
:tint-opacity="0.05"
:frost-blur="10"
width="400px"
height="300px"
>
<h1>Your Content Here</h1>
</SolidGlass>
</template>
<script>
import { SolidGlassVue } from "solid-glass/vue";
import "solid-glass/style.css";
export default {
components: {
SolidGlass: SolidGlassVue,
},
};
</script>| Property | Type | Default | Description |
|---|---|---|---|
shadowColor |
string | 'rgba(255, 255, 255, 0.7)' |
Inner shadow color |
shadowBlur |
number | 7 |
Shadow blur radius in pixels |
shadowSpread |
number | 0 |
Shadow spread radius in pixels |
shadowOffset |
number | 0 |
Shadow offset |
tintColor |
string | '255, 255, 255' |
Glass tint color (RGB format) |
tintOpacity |
number | 0.04 |
Glass tint opacity (0-1) |
frostBlur |
number | 2 |
Backdrop blur amount in pixels |
noiseFrequency |
number | 0.008 |
Turbulence noise frequency |
distortionStrength |
number | 77 |
Distortion effect strength |
borderRadius |
number | 28 |
Border radius in pixels |
Update a single option dynamically.
glass.updateOption("tintOpacity", 0.1);Remove the glass effect and clean up resources.
glass.destroy();const frostedGlass = new SolidGlass(element, {
tintColor: "255, 255, 255",
tintOpacity: 0.1,
frostBlur: 15,
noiseFrequency: 0.005,
distortionStrength: 50,
});const crystalGlass = new SolidGlass(element, {
tintColor: "0, 255, 255",
tintOpacity: 0.05,
frostBlur: 5,
noiseFrequency: 0.015,
distortionStrength: 100,
shadowColor: "rgba(0, 255, 255, 0.5)",
});const minimalGlass = new SolidGlass(element, {
tintOpacity: 0.02,
frostBlur: 8,
noiseFrequency: 0,
distortionStrength: 0,
});# Clone the repository
git clone https://github.com/iplanwebsites/solid-glass.git
cd solid-glass
# Install dependencies
npm install
# Run the demo
npm run dev# Build the library
npm run build
# Preview the build
npm run previewsolid-glass/
βββ src/
β βββ core/ # Core implementation
β βββ vanilla/ # Vanilla JS exports
β βββ react/ # React component
β βββ vue/ # Vue component
β βββ styles/ # CSS styles
βββ demo/ # Vue demo application
βββ dist/ # Build output
- Chrome/Edge β (Full support)
- Firefox
β οΈ (Not supported, but fallback to basicBlur mode) - Opera β (Full support)
- Safari
β οΈ (Partial - blur works, but not the distortion) - Mobile browsers β (Untested)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript Support: Add comprehensive TypeScript definitions and type safety
- Better Choice of Shaders: Expand beyond just noise for refraction with additional shader options like:
- Perlin noise variations
- Shape distortions
- Custom shader support
- Better fallback logic for browser with limited support
- More Browser Support: Improve compatibility with Firefox and Safari, test mobile browsers
- Appleβs upcoming iOS 26 Liquid Glass desig
- chakachukβs CodePen demo for the original glass-distortion filter setup.
- Liquid glass HTML experiment by @archisvaze: https://github.com/archisvaze/liquid-glass
MIT Β© fmenard
Inspired by Apple new UI design and the beauty of light refraction in nature.
Note: This npm module is NOT affiliated with Apple in any ways
