Skip to content

๐ŸŒ“ Add dark and light mode support to swiftUI Color

License

Notifications You must be signed in to change notification settings

sentryco/HybridColor

Repository files navigation

Tests codebeat badge

๐ŸŒ“ HybridColor

HybridColor is a Swift library designed for both macOS and iOS. It offers a seamless way to create SwiftUI colors that adapt to light and dark modes, enhancing the user interface experience across different environments.

Requirements

  • macOS v14 and later
  • iOS 17 and later
  • Swift 5.9 and later

Installation

dependencies: [
    .package(url: "https://github.com/sentryco/HybridColor.git", branch: "main")
]

Usage

import SwiftUI
import HybridColor

#Preview {
    struct ContentView: View {
        var body: some View {
            Text("Hello, world!")
                .foregroundColor(.whiteOrBlack) // white in dark-mode, black in light-mode
                .padding()
                .background(.init(light: .white, dark: .black))
        }
    }
    return Group {
        ContentView()
            .preferredColorScheme(.light)
        ContentView()
            .preferredColorScheme(.dark)
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Todo:

  • Add systemGreen, systemPink, etc

About

๐ŸŒ“ Add dark and light mode support to swiftUI Color

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages