<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColor/init(name:dynamicProvider:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColor(cm)colorWithName:dynamicProvider:"
  },
  "title" : "init(name:dynamicProvider:)"
}
-->

# init(name:dynamicProvider:)

Creates a dynamic catalog color with a provider that’s used to resolve the exact color value, calculated on first use.

```
init(name colorName: NSColor.Name?, dynamicProvider: @escaping (NSAppearance) -> NSColor)
```

## Discussion

When methods on a color need color component values, AppKit calls the provider with [`currentDrawingAppearance`](/documentation/AppKit/NSAppearance/currentDrawingAppearance). The provider can use the appearance to return another color to use for drawing. For example, if you create a color matching [`systemYellow`](/documentation/AppKit/NSColor/systemYellow) for Light appearance, you’ll get a color matching [`systemYellow`](/documentation/AppKit/NSColor/systemYellow) for Dark appearance when using Dark Mode. As often as possible, use the given appearance.

The `colorName` is equal to the identity of the color and should be universally unique; if `nil`, the system generates a unique name.

The name and the Light (aqua) appearance are encoded as part of this color. If a color is already registered with the same name as the decoded color, the decoded color joins the other color and becomes dynamic again.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)