fromHex
Convert a hex string (#rgb, #rgba, #rrggbb or #rrggbbaa; the # is optional) to a Color.
import { fromHex } from '@pbroom/color-kit';index.ts:158function fromHex(hex: string): Color;Parameters
- hex
string - Hex color string
Returns
Throws
- When
hexhas an invalid length or a non-hex digit
Example
import { fromHex, toCss } from '@pbroom/color-kit';
toCss(fromHex('#3b82f6'), 'oklch'); // → 'oklch(0.6231 0.188 259.81)'