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.
- macOS v14 and later
- iOS 17 and later
- Swift 5.9 and later
dependencies: [
.package(url: "https://github.com/sentryco/HybridColor.git", branch: "main")
]
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)
}
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Add systemGreen, systemPink, etc