{"id":15170567,"url":"https://github.com/0xwdg/colors","last_synced_at":"2025-07-18T08:06:42.845Z","repository":{"id":254424606,"uuid":"846245461","full_name":"0xWDG/Colors","owner":"0xWDG","description":"Colors is a Swift Package to enable all system colors in SwiftUI trough a Color extension. Colors which were previously only available in UIColor/NSColor are now available in Color as well.","archived":false,"fork":false,"pushed_at":"2025-02-20T20:15:18.000Z","size":442,"stargazers_count":33,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T13:29:53.483Z","etag":null,"topics":["0xwdg","appkit","color","hacktoberfest","nscolor","package","spm","swift","swiftlang","swiftui","uicolor","uikit","xcode"],"latest_commit_sha":null,"homepage":"https://0xwdg.github.io/Colors/","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/0xWDG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-22T20:08:08.000Z","updated_at":"2025-05-06T07:56:46.000Z","dependencies_parsed_at":"2024-08-23T11:47:05.862Z","dependency_job_id":"c75a5a01-d56d-47c7-9aa4-78e4f8fca4b4","html_url":"https://github.com/0xWDG/Colors","commit_stats":null,"previous_names":["0xwdg/colors"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/0xWDG/Colors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FColors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FColors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FColors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FColors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xWDG","download_url":"https://codeload.github.com/0xWDG/Colors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FColors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265725142,"owners_count":23817966,"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":["0xwdg","appkit","color","hacktoberfest","nscolor","package","spm","swift","swiftlang","swiftui","uicolor","uikit","xcode"],"created_at":"2024-09-27T08:04:08.528Z","updated_at":"2025-07-18T08:06:42.837Z","avatar_url":"https://github.com/0xWDG.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Colors\n\nColors is a Swift Package to enable all system colors in SwiftUI trough a `Color` extension.  \nColors which were previously only available in `UIColor`/`NSColor` are now available in `Color` as well.\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FColors%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/0xWDG/Colors)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FColors%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/0xWDG/Colors)\n[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager)\n![License](https://img.shields.io/github/license/0xWDG/Colors)\n\nAvailable colors are: `lightText`, `darkText`, `placeholderText`, `label`, `secondaryLabel`, `tertiaryLabel`, `quaternaryLabel`, `systemBackground`, `secondarySystemBackground`, `tertiarySystemBackground`, `systemFill`, `secondarySystemFill`, `tertiarySystemFill`, `quaternarySystemFill`, `systemGroupedBackground`, `secondarySystemGroupedBackground`, `tertiarySystemGroupedBackground`, `systemGray`, `systemGray2`, `systemGray3`, `systemGray4`, `systemGray5`, `systemGray6`, `separator`, `opaqueSeparator`, `link`, `systemBlue`, `systemCyan`, `systemMint`, `systemPurple`, `systemGreen`, `systemYellow`, `systemOrange`, `systemPink`, `systemRed`, `systemTeal`, `systemIndigo`, `scrubberTexturedBackground`, `textBackgroundColor`, `controlTextColor`, `quaternaryLabelColor`, `findHighlightColor`, `highlightColor`, `shadowColor`, `windowFrameTextColor`, `windowBackgroundColor`, `keyboardFocusIndicatorColor`, `separatorColor`, `selectedControlColor`, `controlBackgroundColor`, `secondaryLabelColor`, `tertiaryLabelColor`, `gridColor`, `alternateSelectedControlTextColor`, `unemphasizedSelectedContentBackgroundColor`, `textColor`, `systemBrown`, `selectedContentBackgroundColor`, `selectedTextColor`, `labelColor`, `placeholderTextColor`, `unemphasizedSelectedTextBackgroundColor`, `disabledControlTextColor`, `headerTextColor`, `linkColor`, `selectedTextBackgroundColor`, `unemphasizedSelectedTextColor`, `controlColor`, `selectedControlTextColor`, `underPageBackgroundColor`, `selectedMenuItemTextColor`.\n\n## Requirements\n\n- Swift 5.9+ (Xcode 15+)\n- iOS 13+, macOS 10.15+\n\n## Installation (Pakage.swift)\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/0xWDG/Colors.git\", branch: \"main\"),\n],\ntargets: [\n    .target(name: \"MyTarget\", dependencies: [\n        .product(name: \"Colors\", package: \"Colors\"),\n    ]),\n]\n```\n\n## Installation (Xcode)\n\n1. In Xcode, open your project and navigate to **File** → **Swift Packages** → **Add Package Dependency...**\n2. Paste the repository URL (`https://github.com/0xWDG/Colors`) and click **Next**.\n3. Click **Finish**.\n\n## Usage\n\n```swift\nimport SwiftUI\nimport Colors\n\nstruct ContentView: View {\n    var body: some View {\n        VStack {\n            Text(\"Hello, World!\")\n                .foregroundColor(Color.disabledControlTextColor)\n        }\n        .padding()\n    }\n}\n```\n\n## Extract color from UIColor/NSColor\n\nUse this to add new/missing colors to the `BaseColor` and `Color` extension.\n\nExtract from **UIKit**:\n```swift\nUIColor.systemPink.createInitializerFor(color: \"systemPink\")\n```\n\nExtract from **AppKit**:\n```swift\nNSColor.systemPink.createInitializerFor(color: \"systemPink\")\n```\n\nOutput:\n```swift\n/// A color that represents the system-provided systemPink color.\npublic static let systemPink = Color.dynamicColor(\n    light: .init(red: 1.00, green: 0.18, blue: 0.33, alpha: 1.00),\n    dark: .init(red: 1.00, green: 0.18, blue: 0.33, alpha: 1.00)\n)\n```\n\n## How to add a new color\n\n1. Add the color to the `BaseColor` struct.\n    ```swift\n    /// A color that represents the system-provided systemPink color.\n    public static let systemPink = Color.dynamicColor(\n        light: .init(red: 1.00, green: 0.18, blue: 0.33, alpha: 1.00),\n        dark: .init(red: 1.00, green: 0.18, blue: 0.33, alpha: 1.00)\n    )\n    ```\n2. Add the color to the `Color` extension.\n   - Use the native `Color`,`NSColor`,`UIColor.colorName` where possible.\n   - Add #if os(iOS) / #if os(macOS) where needed.\n   - Example (works on almost all versions):\n   ```swift\n    /// A color that represents the system-provided pink color.\n    public static var systemPink: Color {\n    #if os(iOS) || os(tvOS)\n        Color(UIColor.systemPink)\n    #elseif os(macOS)\n        Color(NSColor.systemPink)\n    #else\n        BaseColor.systemPink\n    #endif\n    }\n    ```\n    - Example 2 (works from a specific iOS/macOS version):\n    ```swift\n    /// A color that represents the system-provided cyan color.\n    public static var systemCyan: Color {\n    #if os(iOS) || os(tvOS)\n        if #available(iOS 15.0, *) {\n            Color(UIColor.systemCyan)\n        } else {\n            BaseColor.systemCyan\n        }\n    #elseif os(macOS)\n        if #available(macOS 12.0, *) {\n            Color(NSColor.systemCyan)\n        } else {\n            BaseColor.systemCyan\n        }\n    #else\n            BaseColor.systemCyan\n    #endif\n    }\n    ```\n\n## Contact\n\n🦋 [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)\n🐘 [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)\n🐦 [@0xWDG](https://x.com/0xWDG)\n🧵 [@0xWDG](https://www.threads.net/@0xWDG)\n🌐 [wesleydegroot.nl](https://wesleydegroot.nl)\n🤖 [Discord](https://discordapp.com/users/918438083861573692)\n\nInterested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fcolors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xwdg%2Fcolors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fcolors/lists"}