A customizable macOS material blur view that goes beyond NSVisualEffectView.
For a deep dive into the internals, see Reverse Engineering NSVisualEffectView.
- Full control over blur radius, saturation, brightness, and tint colors
- State-aware materials with active, inactive, emphasized, and accessibility configurations
- Blend groups for seamless material continuity across multiple views
- Behind-window blending to sample content from the desktop and other apps
- SwiftUI and AppKit support
The repository includes a demo app for experimenting with effect configurations in real time. Open Demo/MaterialDemo.xcodeproj to try it out.
Add MaterialView to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/OskarGroth/MaterialView.git", from: "1.0.0")
]import MaterialView
MaterialView(effect: .panelDark, cornerRadius: 12)
.frame(width: 300, height: 200)import MaterialView
let materialView = NSMaterialView()
materialView.effect = .panelDark
materialView.cornerRadius = 12Create your own materials with full control over the appearance:
let customEffect = NSMaterialView.Effect(
active: .MaterialStyle(
backgroundColor: NSColor(white: 0.15, alpha: 0.5),
tintColor: NSColor(white: 0.1, alpha: 0.3),
tintFilter: kCAFilterLightenBlendMode,
saturationFactor: 1.8,
brightnessFactor: 0.02,
blurRadius: 30
),
rimColor: (inner: .white.withAlphaComponent(0.15), outer: .clear),
rimWidth: (inner: 1, outer: 0)
)MaterialView relies on undocumented CoreAnimation classes (CABackdropLayer, CAFilter) and private window properties. While these APIs have been stable for years and are used extensively by Apple's own frameworks, they could change in future macOS releases.
MIT License. See LICENSE for details.