Garnish helps you calculate some ideal colors for text and UI elements in light and dark themes, ensuring contrast and visual harmony based on luminance.
- Dynamic Background Colors: Automatically adjust colors for light or dark themes with customizable blending.
- Contrast-Optimized Foreground Colors: Ensure text is readable against any background.
- Color Utilities: Access brightness, luminance, and contrast ratio calculations.
- Blending & Manipulation: Blend colors dynamically and adjust brightness for visual balance.
Join the Kyo Discord to discuss features, share feedback, or connect with other users. It's a great place to collaborate and engage with the community.
Garnish is available as a Swift Package. Add it to your project using the following steps:
- In Xcode, go to File > Add Packages...
- Enter the repository URL:
[https://github.com/Aeastr/Garnish.git]
- Add the package to your desired targets.
Adjust a color to create a background that adapts to the current color scheme.
let backgroundColor = Garnish.bgBase(for: .blue, in: .light)
Ensure text or elements are readable against a given background using contrastingForeground
.
let foregroundColor = Garnish.contrastingForeground(for: .blue)
More Examples in Docs and Demo in Sources/Garnish/Demo.swift
Explore detailed documentation for each function and extension under the docs/
directory:
- Dynamic Background Colors (
bgBase
) - Dynamic Color Adjustment (
colorBase
) - Contrast-Optimized Foregrounds (
contrastingForeground
) - Relative Luminance (
relativeLuminance
) - Brightness Calculation (
brightness
) - Determine Color Scheme (
determineColorScheme
) - Contrast Ratio (
contrastRatio
) - UIColor Extensions (
blend
,relativeLuminance
)
We welcome contributions to enhance Garnish! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.