How electron-liquid-glass works
mainThe library provides native macOS glass effects by integrating directly with the system's view hierarchy.
Core Mechanisms
- Native Integration: Uses Objective-C++ to create
NSGlassEffectViewinstances. - View Hierarchy: Instead of overlaying content, it inserts glass views behind your web content.
- Automatic Updates: The library listens for system appearance changes (e.g., switching between Light and Dark mode) to keep the glass effect in sync with the OS.
- Fallback Behavior: It uses the private
NSGlassEffectViewAPI when available, falling back to the publicNSVisualEffectViewon older systems. - Memory Management: It handles the native view lifecycle to prevent memory leaks.