Skip to content

@graphty/graphty-element / schema / hexToRgb

Function: hexToRgb() ​

hexToRgb(hex): RgbColor | null

Defined in: graphty-element/src/utils/styleHelpers/color/interpolation.ts:57

Parse a hex color string to RGB components.

Parameters ​

hex ​

string | null | undefined

Hex color string (e.g., "#440154"), or a missing value.

Returns ​

RgbColor | null

The three channels, or null if the input is not a six-digit hex colour.

Example ​

ts
hexToRgb("#440154")  // { r: 68, g: 1, b: 84 }
hexToRgb("#fff")     // null
hexToRgb(undefined)  // null