Skip to content

OskarGroth/MaterialView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaterialView

A customizable macOS material blur view that goes beyond NSVisualEffectView.

For a deep dive into the internals, see Reverse Engineering NSVisualEffectView.

MaterialView

Features

  • 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

Demo App

The repository includes a demo app for experimenting with effect configurations in real time. Open Demo/MaterialDemo.xcodeproj to try it out.

Demo

Installation

Add MaterialView to your project using Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/OskarGroth/MaterialView.git", from: "1.0.0")
]

Usage

SwiftUI

import MaterialView

MaterialView(effect: .panelDark, cornerRadius: 12)
    .frame(width: 300, height: 200)

AppKit

import MaterialView

let materialView = NSMaterialView()
materialView.effect = .panelDark
materialView.cornerRadius = 12

Custom Effects

Create 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)
)

Notes

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.

License

MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published