Skip to content

toHex

toHex(color, digits?): string

Defined in: packages/format-css-color/src/print-css-color.ts:119

A resolved colour as a hex literal.

The 3- and 4-digit forms are only exact when every channel’s two digits match; otherwise they round to the nearest such value, which is a visible change. Ask for them only when a short literal matters more than fidelity.

ResolvedColor

HexDigits

Default 6, or 8 when the colour is not fully opaque.

string