{"id":13338742,"url":"https://github.com/vsanthanam/MaterialColors-Swift","last_synced_at":"2025-03-11T10:31:54.018Z","repository":{"id":48936239,"uuid":"382457292","full_name":"vsanthanam/MaterialColors-Swift","owner":"vsanthanam","description":"A swift package for implementing colors from Material Design","archived":false,"fork":false,"pushed_at":"2021-10-12T17:20:25.000Z","size":1413,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T18:45:11.751Z","etag":null,"topics":["appkit","cgcolor","ios","macos","material-design","nscolor","nsview","spm","swift","swift-library","swiftui","tvos","uicolor","uikit","uiview","watchos","xcode"],"latest_commit_sha":null,"homepage":"https://swiftmaterialcolors.dev","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/vsanthanam.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":"2021-07-02T20:31:30.000Z","updated_at":"2021-10-12T17:20:29.000Z","dependencies_parsed_at":"2022-09-11T21:11:05.438Z","dependency_job_id":null,"html_url":"https://github.com/vsanthanam/MaterialColors-Swift","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsanthanam%2FMaterialColors-Swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsanthanam%2FMaterialColors-Swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsanthanam%2FMaterialColors-Swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsanthanam%2FMaterialColors-Swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsanthanam","download_url":"https://codeload.github.com/vsanthanam/MaterialColors-Swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015443,"owners_count":20222082,"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":["appkit","cgcolor","ios","macos","material-design","nscolor","nsview","spm","swift","swift-library","swiftui","tvos","uicolor","uikit","uiview","watchos","xcode"],"created_at":"2024-07-29T19:17:08.998Z","updated_at":"2025-03-11T10:31:52.602Z","avatar_url":"https://github.com/vsanthanam.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MaterialColors\n\nMaterialColors is a swift package for quickly implementing colors from [Material Design](https://www.material.io) in your applications.\nIt supports UIKit, AppKit, and SwiftUI, as well as platform light and dark user interface styles\n\n## Setup\n\n`MaterialColors` uses the [The Swift Package Manager](https://swift.org/package-manager/) for distrubition. For now, this is the only supported method of installation, but others will be added soon.\n\nAdd `MaterialColors` to your `Package.swift` file like so:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/vsanthanam/MaterialColors-Swift.git\", .upToNextMajor(from: \"0.0.0\"))\n]\n```\n\n## Usage\n\n### UIKit\n\n```swift\nimport MaterialColors\nimport UIKit\n\nlet view = UIView()\nview.backgroundColor = .material(.red400)\n```\n```swift\nimport MaterialColors\nimport UIKit\n\nlet dynamicView = UIView()\nview.backgroundColor = .material(light: .grey50, dark: .grey400)\n```\n\n### AppKit\n\n```swift\nimport AppKit\nimport MaterialColors\n\nlet view = NSView()\nview.backgroundColor = .material(.green50)\n```\n\n### CoreGraphics\n\n```swift\nimport CoreGraphics\nimport MaterialColors\nimport UIKit\n\nlet view = UIView()\nview.layer.background = .material(.purple300)\n```\n```swift\nimport AppKit\nimport CoreGraphics\nimport MaterialColors\n\nlet view = NSView()\nview.layer.background = .material(.orange200)\n```\n\n### SwiftUI\n```swift\nimport MaterialColors\nimport SwiftUI\n\nstruct MyView: View {\n\n    var body: some View {\n        Rectangle()\n            .foregroundColor(.material(.deepPurple400))\n    }\n\n}\n```\n\n### Strings\n\nYou can also create material colors from strings and string literals. This can be useful if you are parsing some value from an http response:\n\n```swift\nimport MaterialColors\nimport UIKit\n\nlet uicolor: UIColor = .material(\"red400\")\n\nlet string = \"red400\"\nlet color = MaterialColor(string)\n\nlet nscolor: NSColor = .material(color)\n```\n\n### Converting Backwards\n\nYou can also determine whether a given color is one of the standard material design colors, and if so, which one it is:\n\n```swift\nimport MaterialColors\nimport UIKit\nimport XCTest\n\nlet materialColor: UIColor = .material(.red400)\nlet nonMaterialColor = UIColor.blue\n\nXCTAssertNil(nonMaterialColor.asMaterialColor)\nXCTAssertEqual(materialColor.asMaterialColor, .red400)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsanthanam%2FMaterialColors-Swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsanthanam%2FMaterialColors-Swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsanthanam%2FMaterialColors-Swift/lists"}