Glassmorphism with CSS Gradients

Build linear, radial, and conic CSS gradients with a visual editor. Drag color stops, pick presets, and copy ready-to-use CSS, Tailwind, or custom property output.

Glassmorphism with CSS Gradients

The glassmorphism effect combines four CSS properties to create a frosted-glass appearance that lets background content show through a translucent, blurred surface. A semi-transparent gradient background tints the glass. backdrop-filter: blur() frosted the content behind the element.1 A translucent border adds the glass-edge highlight. A subtle box-shadow grounds the panel.

The gradient must use colors with alpha below 1: solid opaque stops block the blur effect entirely. Consequently, rgba() or oklch() colors with alpha between 0.05 and 0.4 keep the glass translucency while adding a color tint to the panel.2 Building on this, Safari requires -webkit-backdrop-filter alongside the standard property for full support.3 Performance is a known consideration: backdrop-filter triggers compositing layer promotion, which consumes GPU memory. For mobile UIs with many glassmorphism panels, limiting the number of active blur layers is important.

What this page covers

  • Tint alpha range 0.05 to 0.4 overall, 0.10 to 0.20 for a light glass effect, 0.25 to 0.35 for a stronger tint
  • backdrop-filter: blur() needs the -webkit- prefix for Safari alongside the standard property

Opens the CSS Gradient Builder with this page's checklist shown at the top of the tool.

Open in the tool →

The four-layer composition

A glassmorphism panel assembles four visual layers.4 First: a semi-transparent gradient background that tints the glass and establishes color. Second: backdrop-filter: blur(12px) that frosted the content behind the element. Third: a 1px solid border using an rgba() or oklch() color at 0.15 to 0.3 alpha, which provides the edge highlight without outlining the panel heavily. Fourth: a box-shadow using a low-alpha dark color for grounding. Each layer contributes a distinct visual property, and removing any one of them diminishes the frosted-glass illusion. Understanding how these four layers interact helps you debug rendering issues: if the blur looks wrong, check the alpha values; if the panel looks flat, verify the border and shadow are both present.

The directional tint created by a diagonal gradient also helps establish a consistent light source across multiple glassmorphism panels on the same page, which reinforces the three-dimensional layering effect that makes the frosted-glass aesthetic feel cohesive rather than arbitrary. For hero sections that overlay rich imagery, a 135deg gradient with a subtle white-to-transparent stop pattern mimics the way real glass catches ambient light from above.

Gradient alpha requirements

The gradient alpha must stay below 1 throughout for the blur to remain visible. A stop at rgba(255, 255, 255, 0.1) for the top (simulating a top-light glass reflection) and rgba(255, 255, 255, 0.03) for the bottom produces a subtle top-lit effect. Yet using a single flat rgba() background-color without a gradient is also valid for glassmorphism; the gradient adds a directional tint quality that flat colors do not have.

Building on this, diagonal gradients (135deg) often read more naturally as a glass surface than vertical or horizontal ones because the angled light catch mimics how real glass reflects ambient light from a window or overhead source, and the directional tint helps establish a consistent light source across multiple glassmorphism panels on the same page.

Why the gradient must use alpha below 1

backdrop-filter applies to the content behind the element. For the blur to remain visible, the element's background must allow some content to show through. A fully opaque background completely blocks the blurred content, making the blur invisible regardless of the backdrop-filter value. Alpha values between 0.05 and 0.4 balance translucency with color tint, which is the range where you can set a glass tint that still lets the blur through instead of flattening it into a solid panel.

Alpha values between 0.05 and 0.4 balance translucency with color tint. At 0.05, the tint is nearly invisible and the blurred background dominates. At 0.4, the tint becomes a strong color overlay and the blur is less visible through it. Yet neither extreme serves the glassmorphism aesthetic well: too little alpha removes the glass color character; too much alpha blocks the blur that defines the style.

Furthermore, OLED displays render low-alpha dark stops as genuinely transparent rather than a very dark opaque color, which affects how the blur appears on high-contrast backgrounds. On OLED panels, a gradient stop at oklch(0 0 0 / 0.05) is genuinely transparent rather than a near-black tint, which means the blur effect is more visible through the dark regions of the gradient than it would be on an LCD panel with the same CSS values. This OLED transparency behavior means you can use darker gradient stops on OLED-targeted designs without sacrificing the blur visibility, allowing for richer dark-mode glassmorphism panels that still let background content show through.

Browser support and compositing layer performance

backdrop-filter has full support in Chrome, Edge, Firefox, and Safari. Safari requires the -webkit-backdrop-filter property in addition to the standard backdrop-filter for complete cross-browser support. Both properties accept the same value: blur(12px). On desktop browsers with dedicated GPUs, the compositing cost is minimal for a few panels, but on mobile browsers and low-end hardware, multiple overlapping backdrop-filter elements can reduce frame rate noticeably during scroll and animation.

GPU compositing cost

backdrop-filter promotes the element to its own GPU compositing layer.5 Each layer consumes GPU memory and requires the browser to composite the blurred background separately from the main page layer. On desktop browsers with dedicated GPUs, this cost is minimal for a few panels. Yet on mobile browsers and low-end hardware, multiple overlapping backdrop-filter elements can reduce frame rate noticeably during scroll and animation.

Consequently, glassmorphism panels should be positioned away from frequently scrolling content, and their count per page should be limited to avoid stacking compositing costs. Building on this, testing glassmorphism performance on mid-range Android hardware (Samsung Galaxy A series) reveals real-world compositing limits that desktop-only testing misses. For pages that need many glassmorphism panels, adding @media (prefers-reduced-motion: reduce) to disable blur on low-end devices provides a graceful fallback that preserves the visual hierarchy without the GPU cost. A practical limit for most mobile layouts is three to four simultaneous backdrop-filter elements visible in the viewport at once; beyond that, consider replacing some panels with a simpler translucent background color that achieves a similar visual weight without the compositing overhead.

Inner shadows and border highlights for the glass edge effect

The glass edge highlight comes from the border, not from a separate visual element. A 1px solid rgba(255,255,255,0.2) border on a dark background produces the edge highlight at zero additional DOM cost. On a lighter background, reducing the alpha to 0.08 to 0.12 maintains the edge definition without making the border appear as a heavy outline that draws attention away from the panel content.

Multiple box-shadow values on a single element compose the glassmorphism shadow system without extra markup. The outer shadow grounds the panel on the page: box-shadow: 0 8px 32px rgba(0,0,0,0.12). An inner shadow adds the top-edge light catch: box-shadow: inset 0 1px 0 rgba(255,255,255,0.15). Combining both with comma separation on the box-shadow property produces the full layered effect in one declaration.

Color-matching the border highlight to the gradient

A gradient background running from a lighter stop at the top to a darker stop at the bottom benefits from matching the border highlight alpha to the top stop's lightness. At oklch(1 0 0 / 0.15) for the top gradient stop, a border at rgba(255,255,255,0.15) continues the same light intensity at the element edge. This consistency across the gradient direction makes the glass surface read as three-dimensional rather than flat with a decorative border applied on top.

When to use this

Use glassmorphism for modal dialogs, floating panels, navigation bars, and card components that overlay rich visual content. Avoid it for high-density UI like data tables, forms, or any layout with many overlapping panels that would stack multiple compositing layers.

Examples

Frosted-glass card overlaid on a gradient hero image

Set background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04)) on the card. Add backdrop-filter: blur(12px) and -webkit-backdrop-filter: blur(12px). Use border: 1px solid rgba(255,255,255,0.18) and box-shadow: 0 4px 24px rgba(0,0,0,0.12) to complete the four-layer composition.

Dark glassmorphism panel on a dark background

For dark backgrounds, use rgba(0,0,0,0.3) as the gradient color instead of white. A dark-tinted glass panel on a dark background creates a differentiated surface without the white-tint approach used for light surfaces. Reduce blur to 8px as heavy blur on dark backgrounds can appear muddy.

Navigation bar with glassmorphism and sticky positioning

Apply position: sticky; top: 0 with the four-layer glassmorphism composition to a nav element. The sticky navigation overlays page content as the user scrolls, with the blurred background making the scroll position visible through the nav. Test scroll performance on mobile; sticky glassmorphism navs are a common source of compositing jank.

Sources
  1. 1.

    MDN Web Docs, "backdrop-filter CSS property," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/backdrop-filter

  2. 2.

    MDN Web Docs, "Stacking context," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Positioned_layout/Stacking_context

  3. 3.

    Adam Argyle and Joe Medley, "Create OS-style backgrounds with backdrop-filter," web.dev, accessed June 2026. https://web.dev/articles/backdrop-filter

  4. 4.

    Paul Lewis, "Stick to Compositor-Only Properties and Manage Layer Count," web.dev, accessed June 2026. https://web.dev/articles/stick-to-compositor-only-properties-and-manage-layer-count

  5. 5.

    Brent Fulgham, "Introducing Backdrop Filters," webkit.org, August 2015. https://webkit.org/blog/3632/introducing-backdrop-filters/

FAQ

The element background is fully opaque, blocking the blurred content. Change the background color to an rgba() or oklch() value with alpha below 1. For example, replace background: white with background: rgba(255,255,255,0.15). The blur appears through the semi-transparent background.

Safari requires -webkit-backdrop-filter alongside the standard backdrop-filter. Include both properties with identical values: backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px). Chrome, Edge, and Firefox support the unprefixed property. Including the prefixed version covers all browsers.

Use alpha values between 0.05 and 0.4. Values below 0.05 make the tint nearly invisible; values above 0.4 obscure the blurred background significantly. A light glass effect typically uses 0.10 to 0.20; a stronger tinted glass uses 0.25 to 0.35. The exact value depends on how visible you want the background content to remain. CapyToolkit's gradient builder outputs the gradient value with your chosen alpha, which you then combine with backdrop-filter and the border in your stylesheet.

backdrop-filter promotes the element to a GPU compositing layer, which costs GPU memory and compositing time. A single glassmorphism panel on a desktop browser has negligible impact. Multiple overlapping panels, especially in scrolling content, can reduce frame rates on mobile hardware. Test on mid-range Android devices to find the practical limit for your design.

Yes. oklch() with an alpha channel: oklch(1 0 0 / 0.15) is equivalent to rgba(255,255,255,0.15) for a white-tinted glass. Using oklch() allows more precise control over the lightness and chroma of the tint color. For example, oklch(0.85 0.05 250 / 0.15) adds a subtle blue tint to the glass without adjusting individual RGB channels.

Additional resources

Guides

CSS Gradient Text with background-clip Apply a CSS gradient to text using background-image and background-clip: text. Browser support, fallback strategy, and live examples with the gradient builder. Animating CSS Gradients with @property Animate CSS gradient stops smoothly using @property custom properties. Browser support, fallback patterns, and OKLCH hue-rotation animations. CSS Mesh Gradient Technique Build mesh-style gradients in CSS using multiple layered radial-gradient() values on the same background-image. No SVG or canvas required. Tailwind CSS v4 Gradient Utilities Complete guide to Tailwind v4 gradient utilities. bg-linear-to-r, bg-radial, bg-conic, from-*, via-*, to-*, and in-oklch modifier reference. CSS Gradient Borders Apply CSS gradient borders using border-image or background-clip masking. Both techniques, browser support comparison, and border-radius workaround. OKLCH Interpolation in CSS Gradients Use OKLCH color space interpolation in CSS gradients with the in oklch modifier. How it eliminates grey midpoints and improves perceptual smoothness. CSS Gradients for Dark Mode UI Design CSS gradients for dark mode using reduced chroma, lower lightness stops, and prefers-color-scheme media queries. Practical patterns for UI surfaces. CSS Background Patterns with Gradients Build repeating CSS background patterns using gradient functions and background-size. Stripes, grids, dots, and diagonal tile techniques without images. Glassmorphism with CSS Gradients Implement the glassmorphism effect with CSS gradients, backdrop-filter blur, and translucent stops. Browser support and performance considerations. CSS Gradient Rendering Across Laptop and Phone Displays How CSS gradients render on the Dell XPS 16, iPhone 17 Pro, MacBook Air M4, MacBook Pro M4 and Galaxy S25: P3 color stops, OKLCH interpolation, OLED blacks and the browser engine each device runs.