tw-glass
Realistic glass refraction for Tailwind. Pure CSS, no JavaScript.
npm install tw-glass@import "tailwindcss";
@import "tw-glass";Glass Refraction
Composable utilities for glass-like displacement effects.
glass
Base utility. Applies SVG displacement filter via backdrop-filter. Requires visible content behind the element.
<div class="glass rounded-xl p-6">Glass panel</div>glass glass-surface
Add frosted surface styling (semi-transparent background + inner glow + shadow).
<div class="glass glass-surface rounded-xl p-6">Frosted panel</div>Displacement Strength
Control how much the background is distorted.
glass-strength-{value}
Displacement intensity. Available: 5, 10, 20 (default), 30, 40, 50. Higher values create more dramatic refraction.
<div class="glass glass-strength-40 rounded-xl p-6">Strong glass</div>52050Chromatic Aberration
Simulates light dispersion through a prism using RGB channel splitting.
glass-chromatic-{value}
Replaces standard displacement with per-channel RGB splitting. Same strength levels: 5, 10, 20, 30, 40, 50.
<div class="glass glass-chromatic-20 rounded-xl p-6">Chromatic glass</div>102040Modifiers
Fine-tune blur, saturation, and brightness with any numeric value.
glass-blur-{px}
Post-displacement blur in pixels. Default: 2px.
<div class="glass glass-blur-6 rounded-xl p-6">Blurry glass</div>0px2px6pxglass-saturation-{pct}
Color saturation as a percentage. Default: 120 (1.2x). 100 = no change.
<div class="glass glass-saturation-200 rounded-xl p-6">Vivid glass</div>50120200glass-brightness-{pct}
Brightness as a percentage. Default: 105. 100 = no change.
<div class="glass glass-brightness-130 rounded-xl p-6">Bright glass</div>80105140Composition
Combine any modifiers with the base glass class.
<div class="glass glass-strength-30 glass-blur-4 glass-saturation-150 glass-surface rounded-xl p-6">
Composed glass panel
</div>