Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

444 B
Raw Blame
import Color from "colorjs.io";

const oklchVariableToHex = (variable: string): string => {
  const rootStyle = getComputedStyle(document.documentElement);
  const rawColor = rootStyle.getPropertyValue(variable).trim();
  const oklchColor = `oklch(${rawColor})`;
  const hexColor = new Color(oklchColor)
    .toGamut({ space: "srgb" })
    .to("srgb")
    .toString({ format: "hex" });
  return hexColor;
};

export default oklchVariableToHex;