Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ objc2 = "0.6"
objc2-app-kit = { version = "0.3.2", default-features = false, features = [
"std",
"objc2-core-foundation",
"objc2-quartz-core",
"NSApplication",
"NSBox",
"NSColor",
"NSGlassEffectView",
"NSGraphics",
Expand All @@ -59,3 +61,7 @@ objc2-foundation = { version = "0.3", default-features = false, features = [
objc2-core-foundation = { version = "0.3", default-features = false, features = [
"std",
] }
objc2-quartz-core = { version = "0.3", default-features = false, features = [
"std",
"objc2-core-foundation",
] }
60 changes: 52 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,55 @@ Make your windows vibrant.
use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial};

#[cfg(target_os = "macos")]
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None).expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None)
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

#[cfg(target_os = "windows")]
apply_blur(&window, Some((18, 18, 18, 125))).expect("Unsupported platform! 'apply_blur' is only supported on Windows");
apply_blur(&window, Some((18, 18, 18, 125)))
.expect("Unsupported platform! 'apply_blur' is only supported on Windows");
```

### macOS Liquid Glass Effect (macOS 26+)

For macOS 26 and newer, you can use the new `apply_liquid_glass` function with the modern glass effect:

```rs
use window_vibrancy::{apply_liquid_glass, LiquidGlassOptions, NSGlassEffectViewStyle};

#[cfg(target_os = "macos")]
{
let options = LiquidGlassOptions::new(NSGlassEffectViewStyle::Clear)
.radius(26.0)
.opaque(false);

apply_liquid_glass(&window, options)
.expect("Unsupported platform! 'apply_liquid_glass' is only supported on macOS 26+");
}
```

**Advanced Usage with WebView:**

If you manage the primary content view yourself (for example a `WKWebView`), you can pass its pointer via the `.content_view()` method so the crate can reparent it into the glass view's `contentView`:

```rs
use window_vibrancy::{apply_liquid_glass, LiquidGlassOptions, NSGlassEffectViewStyle};
use std::ptr::NonNull;

#[cfg(target_os = "macos")]
{
let webview: NonNull<std::ffi::c_void> = find_webview(&window);

let options = LiquidGlassOptions::new(NSGlassEffectViewStyle::Clear)
.radius(26.0)
.content_view(webview);

apply_liquid_glass(&window, options)
.expect("Failed to apply liquid glass");
}
```

For a complete example of WebView integration with Tauri, see [`examples/tauri/src-tauri/src/main.rs`](https://github.com/tauri-apps/window-vibrancy/blob/dev/examples/tauri/src-tauri/src/main.rs).

## Tauri

if you are using tauri, don't forget to:
Expand All @@ -36,12 +79,13 @@ For a more complete example of usage with [tauri](https://tauri.app/), see [`exa

## Available functions

| Function | Supported platforms | Notes |
|:----------------------------------|:----------------------------:|:---------------------------------------------------------------------------------------------------|
| `apply_blur`&`clear_blur` | Windows 7/10/11 (22H1 only) | Bad performance when resizing/dragging the window on Windows 11 build 22621+. |
| `apply_acrylic`&`clear_acrylic` | Windows 10/11 | Bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. |
| `apply_mica`&`clear_mica` | Windows 11 | |
| `apply_vibrancy`&`clear_vibrancy` | macOS 10.10 and newer | |
| Function | Supported platforms | Notes |
|:------------------------------------------|:----------------------------:|:---------------------------------------------------------------------------------------------------|
| `apply_blur`&`clear_blur` | Windows 7/10/11 (22H1 only) | Bad performance when resizing/dragging the window on Windows 11 build 22621+. |
| `apply_acrylic`&`clear_acrylic` | Windows 10/11 | Bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. |
| `apply_mica`&`clear_mica` | Windows 11 | |
| `apply_vibrancy`&`clear_vibrancy` | macOS 10.10 and newer | |
| `apply_liquid_glass`&`clear_liquid_glass` | macOS 26 and newer | Modern glass effect with customizable radius, tint color, and opacity options. |

## Screenshots

Expand Down
4 changes: 3 additions & 1 deletion examples/tao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ fn main() {

#[cfg(target_os = "macos")]
{
apply_liquid_glass(&window, NSGlassEffectViewStyle::Clear, None, Some(26.0))
let options = LiquidGlassOptions::new(NSGlassEffectViewStyle::Clear).radius(26.0);

apply_liquid_glass(&window, options)
.expect("Unsupported platform! 'apply_liquid_glass' is only supported on macOS 26+");
}

Expand Down
Loading
Loading