https://github.com/sentryco/hybridcolor
🌓 Add dark and light mode support to swiftUI Color
https://github.com/sentryco/hybridcolor
Last synced: 3 months ago
JSON representation
🌓 Add dark and light mode support to swiftUI Color
- Host: GitHub
- URL: https://github.com/sentryco/hybridcolor
- Owner: sentryco
- License: mit
- Created: 2024-03-07T07:02:55.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-15T15:02:26.000Z (3 months ago)
- Last Synced: 2025-02-15T16:18:46.370Z (3 months ago)
- Language: Swift
- Size: 38.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/sentryco/HybridColor/actions/workflows/Tests.yml)
[](https://codebeat.co/projects/github-com-sentryco-hybridcolor-main)# 🌓 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
```swift
dependencies: [
.package(url: "https://github.com/sentryco/HybridColor.git", branch: "main")
]
```## Usage
```swift
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](https://choosealicense.com/licenses/mit/)
## Todo:
- Add systemGreen, systemPink, etc