{"id":13563937,"url":"https://github.com/luckymarmot/ThemeKit","last_synced_at":"2025-04-03T20:32:33.305Z","repository":{"id":42136277,"uuid":"67435588","full_name":"luckymarmot/ThemeKit","owner":"luckymarmot","description":"macOS theming library","archived":false,"fork":false,"pushed_at":"2021-08-18T07:34:50.000Z","size":53573,"stargazers_count":881,"open_issues_count":2,"forks_count":43,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-13T22:02:23.947Z","etag":null,"topics":["dark-theme","darkmode","theme-changes","theming","user-themes"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luckymarmot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-05T16:25:06.000Z","updated_at":"2024-10-06T15:06:19.000Z","dependencies_parsed_at":"2022-09-09T16:41:25.236Z","dependency_job_id":null,"html_url":"https://github.com/luckymarmot/ThemeKit","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckymarmot%2FThemeKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckymarmot%2FThemeKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckymarmot%2FThemeKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckymarmot%2FThemeKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckymarmot","download_url":"https://codeload.github.com/luckymarmot/ThemeKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223030801,"owners_count":17076505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dark-theme","darkmode","theme-changes","theming","user-themes"],"created_at":"2024-08-01T13:01:24.738Z","updated_at":"2025-04-03T20:32:33.296Z","avatar_url":"https://github.com/luckymarmot.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cp align=\"left\" style=\"margin-top: 20px;\"\u003e\n  \u003cimg src=\"https://github.com/luckymarmot/ThemeKit/raw/master/Imgs/ThemeKit@2x.png\" width=\"377\" height=\"105\" alt=\"ThemeKit\" /\u003e\n\u003c/p\u003e\n\n![macOS](https://img.shields.io/badge/os-macOS%2010.10%2B-green.svg?style=flat)\n![Swift4](https://img.shields.io/badge/swift-5.4.1-green.svg?style=flat)\n![Release](https://img.shields.io/badge/release-1.4.0-blue.svg?style=flat)\n![MIT](https://img.shields.io/badge/license-MIT-lightgray.svg)\n![CocoaPods](https://img.shields.io/badge/dep-CocoaPods-orange.svg)\n![Carthage](https://img.shields.io/badge/dep-Carthage-orange.svg)\n\n## Summary\n\n*ThemeKit* is a lightweight theming library completely written in Swift that provides theming capabilities to both Swift and Objective-C macOS applications.\n\n*ThemeKit* is brought to you with ❤️ by [Nuno Grilo](http://nunogrilo.com) and the [Paw](https://paw.cloud) [team](https://github.com/orgs/luckymarmot/people).\n\n\u003cp align=\"left\"\u003e\n  \u003cimg src=\"https://github.com/luckymarmot/ThemeKit/raw/master/Imgs/ThemeKit.gif\" width=\"675\" height=\"378\" alt=\"ThemeKit Animated Demo\" /\u003e\n\u003c/p\u003e\n\n\n### QuickStart\n\n* Download the [ThemeKit Demo](https://github.com/luckymarmot/ThemeKit/raw/master/Demo/Bin/Demo.zip) binary and give it a try!\n* Read the [Make your macOS app themable](https://medium.com/@nfgrilo/make-your-macos-app-themable-30dbfe4f5ef0) article (simple tutorial). \n* Check the [ThemeKit Docs](http://themekit.nunogrilo.com). \n\n## Table of Contents\n* [Summary](#summary)\n* [Features](#features)\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Simple Usage](#simple-usage)\n  * [Advanced Usage](#advanced-usage)\n     * [Observing theme changes](#observing-theme-changes)\n     * [Manually theming windows](#manually-theming-windows)\n     * [NSWindow extension](#nswindow-extension)\n* [Theme-aware Assets](#theme-aware-assets)\n* [Creating Themes](#creating-themes)\n  * [Native Themes](#native-themes)\n  * [User Themes](#user-themes)\n* [FAQ](#faq)\n* [License](#license)\n\n## Features\n\n- Written in Swift 4.2\n- Optional configuration, none required\n- Neglected performance impact\n- Automatically theme windows (configurable)\n- Themes:\n  - [`LightTheme`](http://themekit.nunogrilo.com/Classes/LightTheme.html) (default macOS appearance)\n  - [`DarkTheme`](http://themekit.nunogrilo.com/Classes/DarkTheme.html)\n  - [`SystemTheme`](http://themekit.nunogrilo.com/Classes/SystemTheme.html) (default theme). Dynamically resolves to `ThemeManager.lightTheme` or `ThemeManager.darkTheme`, depending on the *\"System Preferences \u003e General \u003e Appearance\"*.\n  - Support for custom themes ([`Theme`](http://themekit.nunogrilo.com/Protocols/Theme.html))\n  - Support for user-defined themes ([`UserTheme`](http://themekit.nunogrilo.com/Classes/UserTheme.html))\n- Theme-aware assets:\n  - [`ThemeColor`](http://themekit.nunogrilo.com/Classes/ThemeColor.html): colors that dynamically change with the theme\n  - [`ThemeGradient`](http://themekit.nunogrilo.com/Classes/ThemeGradient.html): gradients that dynamically change with the theme\n  - [`ThemeImage`](http://themekit.nunogrilo.com/Classes/ThemeImage.html): images that dynamically change with the theme\n  - Optional override of `NSColor` named colors (e.g., `labelColor`) to dynamically change with the theme\n\n## Installation\n\n|ThemeKit Version|Swift Version|\n|----------------|-------------|\n|1.0.0           |      3.0    |\n|1.1.0           |      4.0    |\n|1.2.0           |      4.1    |\n|1.2.3           |      4.2    |\n\nThere are multiple options to include *ThemeKit* on your project:\n\n- **[CocoaPods](https://cocoapods.org)**\n\n  Add to your `Podfile`:\n\n  ```Podfile\n  use_frameworks!\n  target '[YOUR APP TARGET]' do\n      pod 'macOSThemeKit', '~\u003e 1.2.0'\n  end\n  ```\n  \n  When using CocoaPods, the ThemeKit module is named `macOSThemeKit`:\n  \n  ```\n  import macOSThemeKit\n  ```\n  \n  \n- **[Carthage](https://github.com/Carthage/Carthage)**\n\n  ```\n  github \"luckymarmot/ThemeKit\"\n  ```\n  \n  Then import ThemeKit module with:\n  \n  ```\n  import ThemeKit\n  ```\n  \n- **Manually**\n  - Either add `ThemeKit.framework` on your project, **or**, manually add source files from the `ThemeKit\\` folder to your project\n  - If importing into a Objective-C project, you will need to include all the Swift related frameworks as well (as reported [here](https://github.com/luckymarmot/ThemeKit/issues/6))\n  \n  Then import ThemeKit module with:\n  \n  ```\n  import ThemeKit\n  ```\n  \n\n## Usage\n\n### Simple Usage\nAt its simpler usage, applications can be themed with a single line command:\n\n##### In Swift:\n\n```swift\nfunc applicationWillFinishLaunching(_ notification: Notification) {\n\t\n\t/// Apply the dark theme\n\tThemeManager.darkTheme.apply()\n\t\n\t/// or, the light theme\n\t//ThemeManager.lightTheme.apply()\n\t\n\t/// or, the 'system' theme, which dynamically changes to light or dark, \n\t/// respecting *System Preferences \u003e General \u003e Appearance* setting.\n\t//ThemeManager.systemTheme.apply()\n\t\n}\n```\n\n##### In Objective-C:\n\n```objc\n- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {\n\t\n\t// Apply the dark theme\n\tTKDarkTheme *darkTheme = TKThemeManager.darkTheme;\n\t[[TKThemeManager sharedManager] setTheme:darkTheme];\n\t\n}\n```\n\n### Advanced Usage\n\nThe following code will define which windows should be automatically themed ([`WindowThemePolicy`](http://themekit.nunogrilo.com/Classes/ThemeManager/WindowThemePolicy.html)) and add support for user themes ([`UserTheme`](http://themekit.nunogrilo.com/Classes/UserTheme.html)):\n\n##### In Swift:\n\n```swift\nfunc applicationWillFinishLaunching(_ notification: Notification) {\n\n\t/// Define default theme.\n\t/// Used on first run. Default: `SystemTheme`.\n\t/// Note: `SystemTheme` is a special theme that resolves to `ThemeManager.lightTheme` or `ThemeManager.darkTheme`,\n\t/// depending on the macOS preference at 'System Preferences \u003e General \u003e Appearance'.\n\tThemeManager.defaultTheme = ThemeManager.lightTheme\n\t\n\t/// Define window theme policy.\n\tThemeManager.shared.windowThemePolicy = .themeAllWindows\n\t//ThemeManager.shared.windowThemePolicy = .themeSomeWindows(windowClasses: [MyWindow.self])\n\t//ThemeManager.shared.windowThemePolicy = .doNotThemeSomeWindows(windowClasses: [NSPanel.self])\n\t//ThemeManager.shared.windowThemePolicy = .doNotThemeWindows\n\t    \n\t/// Enable \u0026 configure user themes.\n\t/// Will use folder `(...)/Application Support/{your_app_bundle_id}/Themes`.\n\tlet applicationSupportURLs = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)\n\tlet thisAppSupportURL = URL.init(fileURLWithPath: applicationSupportURLs.first!).appendingPathComponent(Bundle.main.bundleIdentifier!)\n\tlet userThemesFolderURL = thisAppSupportURL.appendingPathComponent(\"Themes\")\n\tThemeManager.shared.userThemesFolderURL = userThemesFolderURL\n\t\n\t/// Change the default light and dark theme, used when `SystemTheme` is selected.\n\t//ThemeManager.lightTheme = ThemeManager.shared.theme(withIdentifier: PaperTheme.identifier)!\n\t//ThemeManager.darkTheme = ThemeManager.shared.theme(withIdentifier: \"com.luckymarmot.ThemeKit.PurpleGreen\")!\n\t\n\t/// Apply last applied theme (or the default theme, if no previous one)\n\tThemeManager.shared.applyLastOrDefaultTheme()\n\t \n}    \n```\n\n##### In Objective-C:\n\n```objc\n- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {\n\n    /// Define default theme.\n    /// Used on first run. Default: `SystemTheme`.\n    /// Note: `SystemTheme` is a special theme that resolves to `ThemeManager.lightTheme` or `ThemeManager.darkTheme`,\n    /// depending on the macOS preference at 'System Preferences \u003e General \u003e Appearance'.\n    [TKThemeManager setDefaultTheme:TKThemeManager.lightTheme];\n    \n    /// Define window theme policy.\n    [TKThemeManager sharedManager].windowThemePolicy = TKThemeManagerWindowThemePolicyThemeAllWindows;\n    //[TKThemeManager sharedManager].windowThemePolicy = TKThemeManagerWindowThemePolicyThemeSomeWindows;\n    //[TKThemeManager sharedManager].themableWindowClasses = @[[MyWindow class]];\n    //[TKThemeManager sharedManager].windowThemePolicy = TKThemeManagerWindowThemePolicyDoNotThemeSomeWindows;\n    //[TKThemeManager sharedManager].notThemableWindowClasses = @[[NSPanel class]];\n    //[TKThemeManager sharedManager].windowThemePolicy = TKThemeManagerWindowThemePolicyDoNotThemeWindows;\n    \n    /// Enable \u0026 configure user themes.\n    /// Will use folder `(...)/Application Support/{your_app_bundle_id}/Themes`.\n    NSArray\u003cNSString*\u003e* applicationSupportURLs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);\n    NSURL* thisAppSupportURL = [[NSURL fileURLWithPath:applicationSupportURLs.firstObject] URLByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier];\n    NSURL* userThemesFolderURL = [thisAppSupportURL URLByAppendingPathComponent:@\"Themes\"];\n    [TKThemeManager sharedManager].userThemesFolderURL = userThemesFolderURL;\n    \n    /// Change the default light and dark theme, used when `SystemTheme` is selected.\n    //TKThemeManager.lightTheme = [[TKThemeManager sharedManager] themeWithIdentifier:PaperTheme.identifier];\n    //TKThemeManager.darkTheme = [[TKThemeManager sharedManager] themeWithIdentifier:@\"com.luckymarmot.ThemeKit.PurpleGreen\"];\n    \n    /// Apply last applied theme (or the default theme, if no previous one)\n    [[TKThemeManager sharedManager] applyLastOrDefaultTheme];\n    \n}\n```\n\nPlease check the **Demo** application source code for a more complete usage example of *ThemeKit*.\n\n#### Observing theme changes\n\nThemeKit provides the following notifications:\n\n- `Notification.Name.willChangeTheme` is sent when current theme is about to change\n- `Notification.Name.didChangeTheme` is sent when current theme did change\n- `Notification.Name.didChangeSystemTheme` is sent when system theme did change (System Preference \u003e General)\n\nExample:\n\n```swift\n// Register to be notified of theme changes\nNotificationCenter.default.addObserver(self, selector: #selector(changedTheme(_:)), name: .didChangeTheme, object: nil)\n\n@objc private func changedTheme(_ notification: Notification) {\n\t// ...\n}\n```\n\nAdditionally, the following properties are KVO compliant:\n\n- [`ThemeManager.shared.theme`](http://themekit.nunogrilo.com/Classes/ThemeManager.html#/s:vC8ThemeKit12ThemeManager5themePS_5Theme_)\n- [`ThemeManager.shared.effectiveTheme`](http://themekit.nunogrilo.com/Classes/ThemeManager.html#/s:vC8ThemeKit12ThemeManager14effectiveThemePS_5Theme_)\n- [`ThemeManager.shared.themes`](http://themekit.nunogrilo.com/Classes/ThemeManager.html#/s:vC8ThemeKit12ThemeManager6themesGSaPS_5Theme__)\n- [`ThemeManager.shared.userThemes`](http://themekit.nunogrilo.com/Classes/ThemeManager.html#/s:vC8ThemeKit12ThemeManager10userThemesGSaPS_5Theme__)\n\nExample:\n\n```swift\n// Register for KVO changes on ThemeManager.shared.effectiveTheme\nThemeManager.shared.addObserver(self, forKeyPath: \"effectiveTheme\", options: NSKeyValueObservingOptions.init(rawValue: 0), context: nil)\n\npublic override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {\n\tif keyPath == \"effectiveTheme\" {\n\t\t// ...\n   }\n}\n```\n\n\n#### Manually theming windows\n\nIn case ([`WindowThemePolicy`](http://themekit.nunogrilo.com/Classes/ThemeManager/WindowThemePolicy.html)) was NOT set to `.themeAllWindows`, you may need to manually theme a window. You can use our `NSWindow` extension for that:\n\n##### [NSWindow Extension](http://themekit.nunogrilo.com/Extensions/NSWindow.html)\n\n- [`NSWindow.theme()`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:FE8ThemeKitCSo8NSWindow5themeFT_T_)\n\n\tTheme window if appearance needs update. Doesn't check for policy compliance.\n\n- [`NSWindow.themeIfCompliantWithWindowThemePolicy()`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:FE8ThemeKitCSo8NSWindow37themeIfCompliantWithWindowThemePolicyFT_T_)\n\n\tTheme window if compliant to `ThemeManager.shared.windowThemePolicy` (and if appearance needs update).\n\n- [`NSWindow.themeAllWindows()`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:ZFE8ThemeKitCSo8NSWindow15themeAllWindowsFT_T_)\n\n\tTheme all windows compliant to `ThemeManager.shared.windowThemePolicy` (and if appearance needs update).\n\t\n- [`NSWindow.windowTheme`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:vE8ThemeKitCSo8NSWindow11windowThemeGSqPS_5Theme__)\n\n\tAny window specific theme.\n   This is, usually, `nil`, which means the current global theme will be used.\n   Please note that when using window specific themes, only the associated `NSAppearance` will be automatically set. All theme aware assets (`ThemeColor`, `ThemeGradient` and `ThemeImage`) should call methods that returns a resolved color instead (which means they don't change with the theme change, you need to observe theme changes manually, and set colors afterwards):\n\n   \t- `ThemeColor.color(for view:, selector:)`\n   \t- `ThemeGradient.gradient(for view:, selector:)`\n   \t- `ThemeImage.image(for view:, selector:)`\n\n   \tAdditionally, please note that system overridden colors (`NSColor.*`) will always use the global theme.\n\n- [`NSWindow.windowEffectiveTheme`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:vE8ThemeKitCSo8NSWindow20windowEffectiveThemePS_5Theme_)\n\n\tReturns the current effective theme (read-only).\n\n- [`NSWindow.windowEffectiveThemeAppearance`](http://themekit.nunogrilo.com/Extensions/NSWindow.html#/s:vE8ThemeKitCSo8NSWindow30windowEffectiveThemeAppearanceGSqCSo12NSAppearance_)\n\n\tReturns the current effective appearance (read-only).\n\n\n## Theme-aware Assets\n\n[`ThemeColor`](http://themekit.nunogrilo.com/Classes/ThemeColor.html), [`ThemeGradient`](http://themekit.nunogrilo.com/Classes/ThemeGradient.html) and [`ThemeImage`](http://themekit.nunogrilo.com/Classes/ThemeImage.html) provides colors, gradients and images, respectively, that dynamically change with the current theme.\n\nAdditionally, named colors from the `NSColor` class defined on the `ThemeColor` subclass extension will override the system ones, providing theme-aware colors.\n\nFor example, a project defines a `ThemeColor.brandColor` color. This will resolve to different colors at runtime, depending on the selected theme:\n\n- `ThemeColor.brandColor` will resolve to `NSColor.blue` if the light theme is selected\n- `ThemeColor.brandColor` will resolve to `NSColor.white` if the dark theme is selected\n- `ThemeColor.brandColor` will resolve to `rgba(100, 50, 0, 0.5)` for some user-defined theme ([`UserTheme`](http://themekit.nunogrilo.com/Classes/UserTheme.html))\n\nSimilarly, defining a `ThemeColor.labelColor` will override `NSColor.labelColor` (`ThemeColor` is a subclass of `NSColor`), and *ThemeKit* will allow `labelColor` to be customized on a per-theme basis as well. \n\nThe [NSColor Extension](http://themekit.nunogrilo.com/Extensions/NSColor.html) may be useful when overriding colors in ThemeColor extensions.\n\n### Fallback Assets\n\nThemeKit provides a simple fallback mechanism when looking up assets in the current theme. It will search for assets, in order:\n\n- the asset name, defined in theme (e.g., `myBackgroundColor`)\n- `fallbackForegroundColor`, `fallbackBackgroundColor`, `fallbackGradient` or `fallbackImage` defined in theme, depending if asset is a foreground/background color, gradient or image, respectively\n- `defaultFallbackForegroundColor`, `defaultFallbackBackgroundColor`, `fallbackGradient` or `defaultFallbackImage` defined internally, depending if asset is a foreground/background color, gradient or image, respectively\n\nHowever, for overridden system named colors, the fallback mechanism is different and simpler:\n\n- the asset name, defined in theme (e.g., `labelColor`)\n- original asset defined in the system (e.g., `NSColor.labelColor`)\n\nPlease refer to [`ThemeColor`](http://themekit.nunogrilo.com/Classes/ThemeColor.html), [`ThemeGradient`](http://themekit.nunogrilo.com/Classes/ThemeGradient.html) and [`ThemeImage`](http://themekit.nunogrilo.com/Classes/ThemeImage.html) for more information.\n\n## Creating Themes\n\n### Native Themes\nFor creating additional themes, you only need to create a class that conforms to the [`Theme`](http://themekit.nunogrilo.com/Protocols/Theme.html) protocol and extends `NSObject`.\n\nSample theme:\n\n```swift\nimport Cocoa\nimport ThemeKit\n\t\nclass MyOwnTheme: NSObject, Theme {\n    \n    /// Light theme identifier (static).\n    public static var identifier: String = \"com.luckymarmot.ThemeKit.MyOwnTheme\"\n    \n    /// Unique theme identifier.\n    public var identifier: String = MyOwnTheme.identifier\n    \n    /// Theme display name.\n    public var displayName: String = \"My Own Theme\"\n    \n    /// Theme short display name.\n    public var shortDisplayName: String = \"My Own\"\n    \n    /// Is this a dark theme?\n    public var isDarkTheme: Bool = false\n    \n    /// Description (optional).\n    public override var description : String {\n        return \"\u003c\\(MyOwnTheme.self): \\(themeDescription(self))\u003e\"\n    }\n    \n    // MARK: -\n    // MARK: Theme Assets\n    \n    // Here you can define the instance methods for the class methods defined \n    // on `ThemeColor`, `ThemeGradient` and `ThemeImage`, if any. Check\n    // documentation of these classes for more details.\n}\n```\n\n### User Themes\nThemeKit also supports definition of additional themes with simple text files (`.theme` files). Example of a very basic `.theme` file:\n\n```ruby\n// ************************* Theme Info ************************* //\ndisplayName = My Theme 1\nidentifier = com.luckymarmot.ThemeKit.MyTheme1\ndarkTheme = true\n\n// ********************* Colors \u0026 Gradients ********************* //\n# define color for `ThemeColor.brandColor`\nbrandColor = $blue\n# define a new color for `NSColor.labelColor` (overriding)\nlabelColor = rgb(11, 220, 111)\n# define gradient for `ThemeGradient.brandGradient`\nbrandGradient = linear-gradient($orange.sky, rgba(200, 140, 60, 1.0))\n \n// ********************* Images \u0026 Patterns ********************** //\n# define pattern image from named image \"paper\" for color `ThemeColor.contentBackgroundColor`\ncontentBackgroundColor = pattern(named:paper)\n# define pattern image from filesystem (relative to user themes folder) for color `ThemeColor.bottomBackgroundColor`\nbottomBackgroundColor = pattern(file:../some/path/some-file.png)\n# define image using named image \"apple\"\nnamedImage = image(named:apple)\n# define image using from filesystem (relative to user themes folder)\nfileImage = image(file:../some/path/some-file.jpg)\n\n// *********************** Common Colors ************************ //\nblue = rgb(0, 170, 255)\norange.sky = rgb(160, 90, 45, .5)\n\n// ********************** Fallback Assets *********************** //\nfallbackForegroundColor = rgb(255, 10, 90, 1.0)\nfallbackBackgroundColor = rgb(255, 200, 190)\nfallbackGradient = linear-gradient($blue, rgba(200, 140, 60, 1.0))\n\n```\n\nTo enable support for user themes, just need to set the location for them:\n\n```swift\n// Setup ThemeKit user themes folder\nThemeManager.shared.userThemesFolderURL = //...\n```\n\nPlease refer to [`UserTheme`](http://themekit.nunogrilo.com/Classes/UserTheme.html) for more information.\n\n\n## FAQ\n\n### **Where can I find the API documentation?**\nDocumentation can be found [here](http://themekit.nunogrilo.com). You can also [install it](dash-feed://http%3A%2F%2Fthemekit%2Enunogrilo%2Ecom%2Fdocsets%2FThemeKit%2Exml) on [Dash](https://kapeli.com/dash).\n\n### **Can the window titlebar/toolbar/tabbar be themed?**\nYes - please check one way to do it on the [Demo project](https://github.com/luckymarmot/ThemeKit/tree/master/Demo).\nBasically, a [TitleBarOverlayView](https://github.com/luckymarmot/ThemeKit/blob/master/Demo/Demo/TitleBarOverlayView.swift) view is added *below* the window title bar, [as shown on the WindowController](https://github.com/luckymarmot/ThemeKit/blob/master/Demo/Demo/WindowController.swift#L45-L82) controller.\n\n### **Can controls be tinted with different colors?**\nOther than the colors set by the inherited appearance - light (dark text on light background) or dark (light text on dark background) - natively, it is not possible to specify different colors for the text and/or background fills of controls (buttons, popups, etc).\n\nFor simple cases, overriding `NSColor` can be sufficient: for example, `NSColor.labelColor` is a named color used for text labels; overriding it will allow to have all labels themed accordingly. You can get a list of all overridable named colors (class method names) with `NSColor.colorMethodNames()`.\n\nFor more complex cases, like views/controls with custom drawing, please refer to next question.\n\n### **Can I make custom drawing views/controls theme-aware?**\nYes, you can! Implement your own custom controls drawing using [Theme-aware Assets](#theme-aware-assets) (`ThemeColor` and `ThemeGradient`) so that your controls drawing will always adapt to your current theme... automatically!\n\nIn case needed (for example, if drawing is being cached), you can observe when theme changes to refresh the UI or to perform any theme related operation. Check *\"Observing theme changes\"* on [Usage](#usage) section above.\n\n### **NSTableView cells are getting a background color after being themed!**\nPlease check [this issue](https://github.com/luckymarmot/ThemeKit/issues/18). This theming issue only affects view-based `NSTableView`s, when placed on sheets, on macOS \u003c 10.14. Please check [this comment](https://github.com/luckymarmot/ThemeKit/issues/18#issuecomment-396553982) for a brief explanation on how to fix it, and a small project demonstrating the issue and the fix.\n\n\n### **Scrollbars appear all white on dark themes!**\nIf the user opts for always showing the scrollbars on *System Preferences*, scrollbars may render all white on dark themes. To bypass this, we need to observe for theme changes and change its background color directly. E.g.,\n\n   ```swift\n   scrollView?.backgroundColor = ThemeColor.myBackgroundColor\n   scrollView?.wantsLayer = true\n   NotificationCenter.default.addObserver(forName: .didChangeTheme, object: nil, queue: nil) { (note) in\n     scrollView?.verticalScroller?.layer?.backgroundColor = ThemeColor.myBackgroundColor.cgColor\n   }\n   ```\n\n### **I'm having font smoothing issues!**\nYou may run into font smoothing issues when you use text without a background color set. Bottom line is, always specify/draw a background when using/drawing text. \n\n   1. For controls like `NSTextField`, `NSTextView`, etc:\n   \n        Specify a background color on the control. E.g.,\n\n        ```swift\n        control.backgroundColor = NSColor.black\n        ```\n\n  2. For custom text rendering:\n\n        First draw a background fill, then enable font smoothing and render your text. E.g.,\n\n        ```swift\n        let context = NSGraphicsContext.current()?.cgContext\n        NSColor.black.set()\n        context?.fill(frame)\n        context?.saveGState()\n        context?.setShouldSmoothFonts(true)\n        \n        // draw text...\n        \n        context?.restoreGState()\n        ```\n\n        As a last solution - if you really can't draw a background color - you can disable font smoothing which can slightly improve text rendering:\n\n        ```swift\n        let context = NSGraphicsContext.current()?.cgContext\n        context?.saveGState()\n        context?.setShouldSmoothFonts(false)\n        \n        // draw text...\n        \n        context?.restoreGState()\n        ```\n\n  3. For custom `NSButton`'s:\n\n        This is more tricky, as you will need to override private methods. If you are distributing your app on the Mac App Store, you must first check if this is allowed.\n    \n        a) override the private method `_backgroundColorForFontSmoothing` to return your button background color.\n    \n        b) if (a) isn't sufficient, you will also need to override `_textAttributes` and change the dictionary returned from the `super` call to provide your background color for the key `NSBackgroundColorAttributeName`.\n\n\n\n## License\n\n*ThemeKit* is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckymarmot%2FThemeKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckymarmot%2FThemeKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckymarmot%2FThemeKit/lists"}