ColorKit

3.2.1

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

What's New

ColorKit 3.2.1

2026-10-04T08:42:28Z

ColorKit 3.2.1 improves export correctness, blending preview text contrast, and guidance for existing color workflows. No new public declarations or source migrations are required.

Fixes and clarity

  • Escape SVG and CSS palette names so punctuation cannot break markup or introduce CSS rules, with parser-based regression tests.
  • Improve blending preview control and result-label text contrast.
  • Clarify global theme lookup versus environment-scoped selection and local overrides; share internal semantic role mapping.
  • Clarify unavailable assessment outcomes, requested palette counts, and cache insertion, eviction, and clearing contracts.
  • Lead DocC with result-bearing color workflows and remove obsolete private helpers.

Export behavior

Exported SVG/CSS bytes can change for names containing punctuation. SVG now returns nil for XML-forbidden characters; CSS returns nil for empty entry names. Handle the existing optional result or correct those names before retrying. CSS normalization and duplicate-name cascade behavior remain unchanged, as do export formats, color conversion, and caching. See the migration note.

Tooling

  • Add reproducible complete assessed-palette benchmark requests in empty and primed cache modes, with retained workload-specific evidence. No production speedup is claimed.
  • Preserve the cache ownership investigation and its experiments; retain the implementation for 3.x.
  • Notify the website repository on publication to initiate its release-documentation workflow.

Validation and limits

Release validation covers strict lint, tooling tests, Release benchmark correctness, the standalone contrast-report example, DocC generation and compiled/runtime documentation examples, released-client/API compatibility on iOS and macOS, and the canonical behavioral matrix including serialized shared-state suites.

Minimum-supported-OS runtime and physical-device coverage are not established by these checks. Existing manual preview gaps remain: spoken VoiceOver, full macOS keyboard/picker operation, and live checkerboard verification. These are not claimed as passing; see the retained preview evidence.

Full changelog · Changes since 3.2.0

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

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Oct 13 2026 19:29:09 GMT-0900 (Hawaii-Aleutian Daylight Time)