Skip to content

pantoken / design/swatches/src / hexToRgb

Fonction: hexToRgb()

hexToRgb(hex): Rgb | undefined

Expérimental

Interpréter #rgb/#rrggbb/#rrggbbaa en canaux 0–255, ou undefined s'il ne s'agit pas d'une couleur hexadécimale.

Paramètres

hex

string

Retourne

Rgb | undefined

Exemple

ts
import { hexToRgb } from "@pantoken/swatches";

hexToRgb("#ff8800"); // { r: 255, g: 136, b: 0 }
hexToRgb("nope"); // undefined