- Contrast Optimization - Generate colors that meet WCAG accessibility standards
- Dynamic Color Adaptation - Colors that work beautifully in light and dark themes
- Mathematical Color Analysis - Precise luminance, brightness, and contrast calculations
- Smart Color Generation - Create contrasting shades and optimized color combinations
- Font Weight Optimization - Improved readability through accessibility-first recommendations
dependencies: [
.package(url: "https://github.com/Aeastr/Garnish.git", from: "1.0.0")
]See Getting Started for detailed setup instructions.
import Garnish
// Generate accessible text color for any background
let textColor = Garnish.contrastingColor(.primary, against: backgroundColor) ?? .primary
// Create a contrasting shade of the same color
let shade = Garnish.contrastingShade(of: .blue) ?? .blue
// Check accessibility compliance
let isAccessible = Garnish.hasGoodContrast(foreground, background)See Documentation for the full API reference.
Garnish includes a demo app to explore its features. Open the Xcode workspace, select GarnishPlayground, and run.
Garnish uses WCAG 2.1 luminance calculations to determine optimal contrast ratios. The core algorithm calculates relative luminance using the sRGB color space formula, then generates contrasting colors that meet accessibility thresholds (4.5:1 for AA, 7:1 for AAA compliance).
Contributions welcome. See CONTRIBUTING.md for guidelines.
MIT. See LICENSE for details.
