@sviy/2oklch
v1.0.0
Published
Zero-bloat Hex to OKLCH converter
Maintainers
Readme
@sviy/2oklch
Zero-bloat HEX to OKLCH converter. No dependencies, single file.
Install
npm install @sviy/2oklchUsage
import { oklch } from '@sviy/2oklch';
oklch.value = '#3490dc';
oklch.css; // 'oklch(0.635 0.143 247.612)'Accepts 3-digit (#fff) and 6-digit (#3490dc) hex, with or without the leading #.
oklch.value = '#ff0000';
oklch.css; // 'oklch(0.628 0.258 29.234)'The result is a ready-to-use CSS value:
const cssVar = `--brand: ${oklch.css};`;API
oklch is a single shared instance.
oklch.value = hex— set the input hex string.oklch.css— read the resultingoklch(...)string.
Invalid input (anything that is not 3- or 6-digit hex) sets oklch.css to "invalid hex".
License
MIT
