Glass Effects
Vanduo glass effects provide an opt-in frosted surface system built with backdrop-filter, translucent layers, highlight sheen, and accessibility fallbacks.
Hero Surface
GlassSurface
Use .vd-glass for frosted surfaces over rich backgrounds, then add size and behavior modifiers as needed.
<div class="vd-glass vd-glass-lg vd-glass-tinted vd-glass-floating">
<h4>GlassSurface</h4>
<p>Use <code>.vd-glass</code> for frosted surfaces over rich backgrounds,
then add size and behavior modifiers as needed.</p>
<button class="vd-btn vd-btn-primary">Primary Action</button>
<button class="vd-btn vd-btn-outline">Secondary</button>
</div>Why Distinctions Can Look Subtle
Blur and opacity are context-dependent. Smooth or homogeneous backgrounds can hide what each class changes.
.vd-glass-mdmatches base.vd-glass, so they are intentionally equivalent..vd-glass-floatingis primarily an interaction state, so static examples can under-sell it.- Use textured backdrops and side-by-side comparisons to make blur, tint, and contrast differences obvious.
Visual Diagnostics Controls
Switch backdrop modes and force floating hover state to inspect class differences under the same conditions.
Size Variants
Look for sharper background detail and a lighter frosted layer.
Equivalent to .vd-glass default; use it for explicit readability.
Background texture softens while color bleed feels denser.
Strongest frosted depth; best for hero overlays and modal foregrounds.
<!-- Size variants: sm / md / lg / xl -->
<div class="vd-glass vd-glass-sm">…</div>
<div class="vd-glass vd-glass-md">…</div> <!-- == .vd-glass -->
<div class="vd-glass vd-glass-lg">…</div>
<div class="vd-glass vd-glass-xl">…</div>Modifiers
Watch for color cast shift while blur and depth remain similar.
State-driven modifier; turn on Force floating hover to preview motion cue.
Use on busy imagery where stronger edge and body contrast improves readability.
<!-- Modifiers -->
<div class="vd-glass vd-glass-tinted">…</div> <!-- tint wash -->
<div class="vd-glass vd-glass-floating">…</div> <!-- lift on hover -->
<div class="vd-glass vd-glass-contrast">…</div> <!-- stronger border -->Glass Tokens
| Token | Purpose | Default |
|---|---|---|
--vd-glass-blur | Backdrop blur amount | 12px |
--vd-glass-saturate | Backdrop saturation boost | 1.8 |
--vd-glass-bg-opacity | Glass opacity base | 0.65 |
--vd-glass-bg-light | Light translucent surface | rgba(255,255,255,var(--vd-glass-bg-opacity)) |
--vd-glass-bg-dark | Dark translucent surface | rgba(30,30,30,var(--vd-glass-bg-opacity)) |
--vd-glass-border-light | Glass edge stroke | rgba(255,255,255,var(--vd-glass-border-alpha)) |
--vd-glass-highlight-alpha | Specular sheen intensity | 0.25 |
--vd-glass-shadow | Depth shadow for floating glass | 0 8px 32px rgba(0,0,0,0.12) |
--vd-glass-noise-opacity | Noise grain overlay strength | 0.03 |
Component Integration
.vd-card-glass for elevated frosted cards. <nav class="vd-navbar vd-navbar-glass">…</nav>
<div class="vd-card vd-card-glass">…</div>
<div class="vd-toast vd-toast-glass">…</div>
<button class="vd-fab vd-fab-glass"><i class="ph ph-plus"></i></button>
<div class="vd-modal vd-modal-glass">…</div>Accessibility
- Glass classes include
prefers-reduced-transparency: reducefallbacks that disable blur and return to solid surfaces. - Floating interactions respect
prefers-reduced-motion: reduce. - Use
.vd-glass-contraston busy backgrounds to improve text legibility. - Keep body text contrast above WCAG AA by testing overlays in both light and dark themes.
Theming
Override glass tokens per app, theme, or component scope.
:root {
--vd-glass-blur: 14px;
--vd-glass-bg-opacity: 0.7;
--vd-glass-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
}
.marketing-hero .vd-glass {
--vd-glass-tint: rgba(34, 184, 207, 0.18);
}Scroll-Activated Glass
Two complementary APIs let you activate glass effects on scroll rather than at page-load time. The framework handles all the observer/listener logic — no custom JavaScript required beyond a single wiring call.
import { ref } from 'vue';
import { useGlass } from "@vanduo-oss/vd3";
import { useNavbarGlassScroll } from "@vanduo-oss/vd3";
// Generic scroll-activated glass (data-glass-scroll)
const root = ref<HTMLElement | null>(null);
useGlass(root); // IntersectionObserver toggles .is-glass-active; cleanup on unmount
// Navbar scroll-activated glass (.vd-navbar-glass)
const navRef = ref<HTMLElement | null>(null);
const isScrolled = useNavbarGlassScroll(navRef);
// <nav ref="navRef" class="vd-navbar vd-navbar-fixed vd-navbar-glass" :class="{ 'vd-navbar-scrolled': isScrolled }">.vd-navbar-glass — Navbar scroll activation
Add .vd-navbar-glass to any .vd-navbar-fixed or .vd-navbar-sticky. The navbar starts fully transparent and gains the frosted glass surface once the user scrolls past its height (or a custom threshold set with data-scroll-threshold). The .vd-navbar-scrolled class is toggled automatically by the framework.
<nav class="vd-navbar vd-navbar-fixed vd-navbar-glass">
...
</nav>
<!-- Custom scroll threshold (px) -->
<nav class="vd-navbar vd-navbar-fixed vd-navbar-glass"
data-scroll-threshold="120">
...
</nav>The docs navbar above is a live example — scroll this page to see the effect.
data-glass-scroll — Generic activation
Any element — sidebar, floating panel, sticky header — can adopt scroll-aware glass by pairing .vd-glass with the data-glass-scroll attribute. The framework uses IntersectionObserver to watch a sentinel element (previous sibling by default, or a CSS selector via data-glass-sentinel) and toggles .is-glass-active automatically.
- No JavaScript required in your markup
- Works on any scrollable container, not just the window
- CSS handles the inactive→active transition via
transition - Falls back to always-active when no sentinel is found
Live demo
<!-- Sentinel: the element whose disappearance triggers glass activation -->
<div id="my-sentinel">...</div>
<!-- Glass element: transparent at rest, frosted once sentinel leaves view -->
<div class="vd-glass"
data-glass-scroll
data-glass-sentinel="#my-sentinel">
Sticky panel content
</div>
<!-- Without explicit sentinel: uses the previous sibling automatically -->
<div id="hero">...</div>
<div class="vd-glass" data-glass-scroll>
Activates when #hero scrolls out of view
</div>