Skip to content

pantoken / design/swatches/src / hexToRgb

函式: hexToRgb()

hexToRgb(hex): Rgb | undefined

實驗性

#rgb/#rrggbb/#rrggbbaa 解析為 0–255 通道,或在不是十六進位顏色時為 undefined

參數

hex

string

回傳

Rgb | undefined

範例

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

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