@pbroom/color-kit/driverColor string input

hasExplicitOklchHue

True when input is an oklch() string whose hue component is stated (anything but none), i.e. the parsed color carries an OKLCH hue of its own. Every other syntax returns false: hex, named colors, rgb(), oklab() and color() have no hue, and the hues of hsl(), hwb() and lch() live in other hue spaces that say nothing about the OKLCH hue of an achromatic color.

functionimport { hasExplicitOklchHue } from '@pbroom/color-kit/driver';color-string-input.ts:97
function hasExplicitOklchHue(  input: string,): boolean;

Only the syntax is checked; parse the string to validate it. Use the result as the explicitHue option of the requested-color setters so an achromatic input keeps the previous hue unless it states one.

Parameters

inputstring

Returns

boolean

Example

TypeScript
import { hasExplicitOklchHue } from '@pbroom/color-kit/driver';

hasExplicitOklchHue('oklch(0.5 0 200)'); // → true
hasExplicitOklchHue('oklch(0.5 0 none)'); // → false
hasExplicitOklchHue('#808080'); // → false