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 },
},
});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.
"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.
"light" | "dark"systemDefaultContext is an optional host-provided fallback.
Context precedence:
- Resolver-level
context - Palette-level
context systemDefaultContext
If no context can be resolved, palette.resolve throws.
"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"output is optional and defaults to oklch.
Runtime support in the current v0.4 implementation:
oklch: supportedoklab: supportedsrgb: supportedp3: supportedhex: supportedrgba: supported
"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"systemDefaultOutput is an optional host-provided output fallback.
Output precedence:
- Resolver-level
output - Palette-level
output systemDefaultOutput- Explicit
oklchdefault
preset is optional and defaults to "neutral".
createPaletteKit({
context: "light",
preset: "soft",
intents,
});Public presets:
softneutralstrong
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:
levelCurvesstateDeltasrelationParamschromaLimits
The default on contrast target is APCA Lc 60. over and under alpha values
are configured per level.