A Swift package for working with Base16 and Base24 color themes, providing easy access to a wide variety of color schemes for your iOS, macOS, watchOS, and tvOS applications.
This package is a Swift API implementation for the TintedTheming/Schemes project, which provides a comprehensive collection of Base16 and Base24 color schemes.
- 🎨 Base16 Theme Support: Complete implementation of the Base16 color specification
- 🌈 Base24 Theme Support: Extended Base24 themes with additional colors
- 🔄 Theme Loading: Load themes from network or local cache
- 🎯 Semantic Colors: Easy access to semantic color mappings (background, foreground, etc.)
- 📱 Multi-Platform: Supports iOS 15+, macOS 12+, watchOS 8+, and tvOS 15+
- ⚡ SwiftUI Ready: Color extensions for seamless SwiftUI integration
Add TintedThemingSwift to your project using Xcode:
- In Xcode, go to File → Add Package Dependencies
- Enter the package URL:
https://github.com/aspauldingcode/TintedThemingSwift
- Select the version and add to your target
Or add it to your Package.swift
:
dependencies: [
.package(url: "https://github.com/aspauldingcode/TintedThemingSwift", from: "1.0.0")
]
import TintedThemingSwift
// Use default themes
let darkTheme = Base16Theme.defaultDark
let lightTheme = Base16Theme.defaultLight
// Access colors
let backgroundColor = darkTheme.base00
let foregroundColor = darkTheme.base05
// Use semantic colors
let redColor = darkTheme.semanticColors["red"] // base08
let blueColor = darkTheme.semanticColors["blue"] // base0D
import SwiftUI
import TintedThemingSwift
struct ContentView: View {
let theme = Base16Theme.defaultDark
var body: some View {
VStack {
Text("Hello, World!")
.foregroundColor(Color(hex: theme.base05))
Rectangle()
.fill(Color(hex: theme.base08))
.frame(width: 100, height: 100)
}
.background(Color(hex: theme.base00))
}
}
import TintedThemingSwift
let loader = TintedThemesLoader()
Task {
do {
let themes = try await loader.loadThemes()
print("Loaded \(themes.count) themes")
// Find a specific theme
if let monokai = themes.first(where: { $0.name == "Monokai" }) {
// Use the theme
}
} catch {
print("Failed to load themes: \(error)")
}
}
The core theme structure with 16 standardized colors:
let theme = Base16Theme.defaultDark
// Check theme variant
if theme.isDark {
print("This is a dark theme")
}
// Access all colors as an array
let allColors = theme.allColors // [base00, base01, ..., base0F]
// Get color by index
if let color = theme.color(at: 8) {
print("Color at index 8: \(color)") // base08
}
Extended themes with 24 colors (Base16 + 8 additional):
let base24Theme = Base24Theme(...)
let base16Version = base24Theme.asBase16Theme // Convert to Base16
Load themes from the official repository:
let loader = TintedThemesLoader()
// Load all themes
let allThemes = try await loader.loadThemes()
// Load specific themes
let specificThemes = try await loader.loadThemes(named: ["Monokai", "Solarized Dark"])
// Load only dark themes
let darkThemes = try await loader.loadDarkThemes()
// Force refresh from network
try await loader.refreshThemes()
Base16 themes follow a standardized 16-color palette:
- base00-03: Background colors (darkest to lightest)
- base04-07: Foreground colors (darkest to lightest)
- base08: Red
- base09: Orange
- base0A: Yellow
- base0B: Green
- base0C: Cyan
- base0D: Blue
- base0E: Purple
- base0F: Brown
- iOS 15.0+ / macOS 12.0+ / watchOS 8.0+ / tvOS 15.0+
- Swift 5.9+ / Xcode 15.0+
- Yams - YAML parsing for theme files
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details.
- TintedTheming/Schemes - The primary source of all color schemes
- Base16 - The original Base16 color scheme specification
📚 For additional documentation and examples, visit the Wiki
🔧 For GitHub Actions workflow documentation, see WORKFLOWS.md
Author: Alex Spaulding