Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
liquid-glass-rs
Native macOS glass effects implementation in Rust. This crate provides a safe Rust interface to create and manage macOS glass effects (NSGlassEffectView) for Tauri windows or any other native macOS windows.
[!IMPORTANT] This project comes from the logic and inspiration of electron-liquid-glass. I ported it into the Rust language for use in the Tauri application. Thank you very much for the work done by Meridius-Labs to explore the Liquid Glass effect API of macOS.
Platform Support
This project will not downgrade unsupported platforms and versions by itself. Please make your own platform judgement.
- macOS 26+: Full NSGlassEffectView support with all material variants
Installation
Add this to your Cargo.toml:
[]
= "0.1.1"
Or install via cargo:
Usage
Basic Example
use ;
// Create a glass view manager
let manager = new;
// Check if glass effects are supported
if !manager.is_supported
// Configure glass options
let options = GlassOptions ;
// Add glass effect to a window
// window_ptr should be a pointer to NSView (from Tauri or native macOS)
let view_id = manager.add_glass_view?;
// The glass effect is now applied!
Advanced Configuration
use ;
let manager = new;
// Create with default options
let options = default;
let view_id = manager.add_glass_view?;
// Set a specific material variant
manager.set_variant?;
// Adjust scrim state (0 = none, 1 = light, 2 = dark)
manager.set_scrim_state?;
// Adjust subdued state
manager.set_subdued_state?;
// Remove the glass view when done
manager.remove_view?;
Available Material Variants
The crate provides access to 24 different glass material styles:
GlassOptions
Integration with Tauri
This crate is particularly useful for Tauri applications running on macOS. Here's a typical integration pattern:
- Get the window's native handle using Tauri's raw window handle API
- Pass the handle to this crate to apply glass effects
- Example Tauri command:
use Runtime;
use ;
Error Handling
The crate provides comprehensive error handling through the GlassError enum:
All methods return Result<T, GlassError> for proper error propagation.
Safety
This crate uses unsafe code to interface with macOS Objective-C APIs through the objc and cocoa crates. All unsafe operations are carefully encapsulated within safe public APIs with proper validation and error handling.
API Documentation
For detailed API documentation, visit docs.rs/liquid-glass-rs.
Examples
Check out the repository for complete working examples.
License
This project is licensed under the MIT License - see the LICENSE file for details.