{"id":23977465,"url":"https://github.com/alexanderwe/swiftui-theming","last_synced_at":"2025-08-22T01:08:58.461Z","repository":{"id":271240168,"uuid":"912336604","full_name":"alexanderwe/swiftui-theming","owner":"alexanderwe","description":"Effortless theming support in SwiftUI","archived":false,"fork":false,"pushed_at":"2025-03-09T17:41:14.000Z","size":8784,"stargazers_count":50,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T03:23:31.791Z","etag":null,"topics":["ios","macos","swiftui","theming","tvos","visionos","watchos"],"latest_commit_sha":null,"homepage":"https://alexanderwe.github.io/swiftui-theming/documentation/overview","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/alexanderwe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2025-01-05T09:38:54.000Z","updated_at":"2025-03-29T15:12:10.000Z","dependencies_parsed_at":"2025-01-06T14:20:54.091Z","dependency_job_id":"2a5f17a2-e759-4697-a375-1e40009f91fa","html_url":"https://github.com/alexanderwe/swiftui-theming","commit_stats":null,"previous_names":["alexanderwe/swiftui-theming"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexanderwe%2Fswiftui-theming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexanderwe%2Fswiftui-theming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexanderwe%2Fswiftui-theming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexanderwe%2Fswiftui-theming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexanderwe","download_url":"https://codeload.github.com/alexanderwe/swiftui-theming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513687,"owners_count":21443204,"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":["ios","macos","swiftui","theming","tvos","visionos","watchos"],"created_at":"2025-01-07T07:39:15.230Z","updated_at":"2025-04-23T20:48:30.124Z","avatar_url":"https://github.com/alexanderwe.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftUI Theming\n\n[![Test](https://github.com/alexanderwe/swiftui-theming/actions/workflows/test.yml/badge.svg)](https://github.com/alexanderwe/swiftui-theming/actions/workflows/test.yml)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Falexanderwe%2Fswiftui-theming%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/alexanderwe/swiftui-theming)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Falexanderwe%2Fswiftui-theming%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/alexanderwe/swiftui-theming)\n\n**SwiftUI Theming** is a library that enables seamless theming in SwiftUI across all Apple platforms, including iOS, macOS, tvOS, watchOS, and visionOS.\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Basic Usage](#basic-usage)\n3. [Make Your App Themeable](#make-your-app-themeable)\n4. [Documentation](#documentation)\n5. [License](#license)\n\n## Installation\n\nYou can integrate **swiftui-theming** into your Xcode project as a Swift Package:\n\n### Xcode GUI\n\n1. Go to **File \u003e Add Package Dependency...**.\n2. Enter the repository URL:\n   `https://github.com/alexanderwe/swiftui-theming`\n3. Choose the library and add it to your desired target.\n\n### Using `Package.swift`\n\nTo add **swiftui-theming** via a `Package.swift` file, include the following dependency:\n\n```swift\n.package(url: \"https://github.com/alexanderwe/swiftui-theming\", from: \"0.1.0\")\n```\n\nThen, add it to your target dependencies:\n\n```swift\n.product(name: \"Theming\", package: \"swiftui-theming\")\n```\n\n---\n\n## Basic Usage\n\n### Step 1: Define Color Styles\n\nBefore creating a new theme, define the color styles available in your app:\n\n```swift\nimport Theming\n\nextension ThemeColorStyle {\n    /// A style for primary labels\n    static let primaryLabel: Self = Self(name: \"primaryLabel\")\n    // Define additional styles as needed\n}\n```\n\n### Step 2: Create a Theme\n\nWith color styles defined, implement a method to create a theme:\n\n```swift\nimport Theming\n// MARK: - Available Themes\nextension Theme {\n    static let `default`: Theme = .createDefaultTheme()\n}\n\n// MARK: - Theme Creation\nextension Theme {\n    private static func createDefaultTheme() -\u003e Theme {\n        let colors: Theme.ColorMap = [\n            .primaryLabel: ThemeColor(lightColor: .primary, darkColor: .primary)\n        ]\n        return Theme(name: \"Default\", colors: colors)\n    }\n}\n```\n\n## Make Your App Themeable\n\nTo enable theming in your app, inject a `ThemeManager` instance into your app's scenes.\n\n### Step 1: Initialize `ThemeManager`\n\nDeclare a `@State` property to hold the `ThemeManager` in your app definition:\n\n```swift\nimport SwiftUI\nimport Theming\n\n@main\nstruct MyApp: App {\n    @State var myThemeManager: ThemeManager = ThemeManager(initialTheme: .default)\n\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n        }\n        .withThemeManager(themeManager: myThemeManager)\n    }\n}\n```\n\n### Step 2: Access Theme Colors in Views\n\nUse the `.themeColor` method to apply theme colors in your SwiftUI views:\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        Text(\"Hello World\")\n            .foregroundStyle(.themeColor(for: .primaryLabel))\n    }\n}\n```\n\n## Documentation\n\nComprehensive documentation is available [here](https://alexanderwe.github.io/swiftui-theming/documentation/overview).\n\n## License\n\nThis library is released under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderwe%2Fswiftui-theming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexanderwe%2Fswiftui-theming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderwe%2Fswiftui-theming/lists"}