Skip to content

Latest commit

 

History

History
144 lines (104 loc) · 2.76 KB

File metadata and controls

144 lines (104 loc) · 2.76 KB

Configuration

createPaletteKit accepts a small explicit configuration object.

import { createPaletteKit } from "@clhaas/palette-kit";

const palette = createPaletteKit({
  context: "light",
  output: "oklch",
  intents: {
    brand: { hue: 260, chroma: 0.14 },
    neutral: { hue: 0, chroma: 0 },
  },
});

intents

Record<string, { hue: number; chroma: number }>

intents is required. Intent names must be flat strings:

  • not empty
  • no whitespace
  • no .

hue must be finite and is normalized to [0, 360). chroma must be finite and greater than or equal to 0.

Intent names must describe semantic meaning only. Names that encode usage, state, relation, level, or visual implementation details are rejected. Keep dimensions such as fill, hover, on, strong, red, and dark in resolver options or configuration instead of intent names.

context

"light" | "dark"

context is optional at palette creation. It becomes the default environment for resolver calls.

Palette Kit never reads prefers-color-scheme, the DOM, or platform state.

Context affects default level curves. Dark context inverts the structural lightness scale for fill and lines while preserving semantic hue and chroma.

systemDefaultContext

"light" | "dark"

systemDefaultContext is an optional host-provided fallback.

Context precedence:

  1. Resolver-level context
  2. Palette-level context
  3. systemDefaultContext

If no context can be resolved, palette.resolve throws.

output

"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"

output is optional and defaults to oklch.

Runtime support in the current v0.4 implementation:

  • oklch: supported
  • oklab: supported
  • srgb: supported
  • p3: supported
  • hex: supported
  • rgba: supported

systemDefaultOutput

"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"

systemDefaultOutput is an optional host-provided output fallback.

Output precedence:

  1. Resolver-level output
  2. Palette-level output
  3. systemDefaultOutput
  4. Explicit oklch default

Presets and Resolver Config

preset is optional and defaults to "neutral".

createPaletteKit({
  context: "light",
  preset: "soft",
  intents,
});

Public presets:

  • soft
  • neutral
  • strong

resolverConfig explicitly overrides the selected preset.

createPaletteKit({
  context: "light",
  preset: "neutral",
  intents,
  resolverConfig: {
    relationParams: {
      on: { contrastTarget: 75 },
    },
    stateDeltas: {
      luminance: { hover: 4 },
    },
  },
});

Supported resolver config sections:

  • levelCurves
  • stateDeltas
  • relationParams
  • chromaLimits

The default on contrast target is APCA Lc 60. over and under alpha values are configured per level.