Skip to content
agisilaosPublic

About

ColorKit is a lightweight Swift Package designed for color manipulation, adaptive theming, and accessibility compliance in SwiftUI.

Topics

Resources

Contributing

Stars

17 stars

Watchers

1 watching

Forks

Latest commit

 

History

284 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ColorKit 🎨

Swift Package Manager Swift Version

Color conversion, contrast assessment, and adaptive themes for SwiftUI.

Swift 6+ · iOS 14+ · macOS 12+

English | Español

Features

  • Color conversion: Hex, RGB, HSL, HSB, CMYK, XYZ, and LAB, with per-representation availability.
  • Contrast and accessibility: WCAG assessment, bounded color adjustments, and color-vision deficiency simulation.
  • Color operations: blending, interpolation, and gradients.
  • Adaptive themes: light/dark colors, semantic roles, and SwiftUI modifiers.
  • Palettes and export: generate candidates, assess them, and export or share palettes.
  • Inspection and previews: visual inspectors, color comparisons, and an interactive catalog.

Installation

In Xcode, choose File → Add Packages and enter:

https://github.com/agisilaos/ColorKit.git

Add the ColorKit library product to the target that will import it.

Upgrading an existing project? Read the migration guide before changing your version requirement.

Quick start

Measure a foreground against an explicit background. Handle unavailable inputs separately from measured contrast:

import SwiftUI
import ColorKit

let foreground = Color(.sRGB, red: 0, green: 0, blue: 0)
let background = Color(.sRGB, red: 1, green: 1, blue: 1)

switch foreground.contrastResult(with: background) {
case .available(let measurement):
    print("Contrast:", measurement.ratio)
    print("Meets WCAG AA:", measurement.passingLevels.contains(.AA))
case .unavailable(let issues):
    print("Foreground issues:", issues.foreground)
    print("Background issues:", issues.background)
}

Supply fixed colors; resolve appearance-dependent colors explicitly first. A translucent foreground composites over an opaque background. A translucent background is unavailable, so argument order matters.

A contrast pass is not whole-app accessibility certification. When generating adjusted colors, inspect the result before using the candidate.

Guides and examples

Run the standalone macOS contrast pair report to assess your own pairs, or explore the interactive catalog in a SwiftUI view:

import SwiftUI
import ColorKit

struct CatalogExample: View {
    var body: some View {
        MainCatalogView()
    }
}

The standalone report has its own platform requirements; see its run instructions.

Project

Contributing · Changelog · Migration · MIT license

About

ColorKit is a lightweight Swift Package designed for color manipulation, adaptive theming, and accessibility compliance in SwiftUI.

Topics

Resources

Contributing

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages