Skip to content

Releases

v2.14.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 18:30
f752bc3

Minor Changes

  • New: lab plugin parses lab() strings and adds toLabString() ❀️ @bardrop

Patch Changes

  • Fix: parsing CMYK colors rounds a channel that is exactly half up, so device-cmyk(0% 0% 0% 90%) is #1a1a1a and not #191919 ❀️ @simonkundrik
  • Fix: parse plain numbers for saturation/lightness in space-separated hsl() and for whiteness/blackness in hwb(), such as hsl(120 50 50) and hwb(120 20 30) ❀️ @bardrop
  • Fix: lab plugin clamps a lightness above 100 to 100, as CSS Color 4 requires, such as { l: 130, a: -60, b: 60 } ❀️ @bardrop
  • Fix: parse space-separated rgb() that mixes numbers and percentages, such as rgb(10% 20 30) ❀️ @bardrop
  • Fix: HSL, HSV and HWB conversions round a channel that is exactly half up, so hwb(0 10% 0%) is #ff1a1a as in browsers, not #ff1919; grayscale(), rotate(), saturate(), lighten() and harmonies() may shift such channels one step too ❀️ @simonkundrik
  • Fix: toCmyk() and toCmykString() round a percent that is exactly half up, so #050808 is c: 38, not c: 37

v2.13.0

Choose a tag to compare

@github-actions github-actions released this 14 Nov 14:32
d9c08b3

Minor Changes

  • New relative option of lighten, darken, saturate and desaturate that scales the current value ❀️ @EricRovell

Patch Changes

  • Parse CSS color function strings faster: the number pattern now matches an integer without backtracking ❀️ @g4lb
  • Fix: lch plugin clamps a negative chroma to 0 instead of flipping the hue, such as lch(50% -20 30) ❀️ @bardrop
  • Fix: lch plugin parses a plain number lightness and a percentage chroma, such as lch(52.2 72.2 56.2) ❀️ @Kernel-Hunter
  • Fix: minify() no longer picks an hsl() string that rounds to a different color
  • Fix: names plugin no longer treats "constructor" and "__proto__" as valid colors ❀️ @Kernel-Hunter

v2.12.0

Choose a tag to compare

@github-actions github-actions released this 10 Nov 23:17
d9a2c7a

Minor Changes

  • Parse numbers in scientific notation (rgb(1e2 .5e1 0 / 25e-2)), as the CSS spec allows

Patch Changes

  • Fix: Parse CSS angle units case-insensitively, so hsl(0.25TURN 50% 50%) means 90 degrees instead of 0.25 ❀️ @blueDaydreaming725
  • Fix: Keep exact colors at the mix() endpoints and when only alpha differs, so a mixture into white no longer turns green after .darken() ❀️ @feritcemkahraman
  • Fix: Type plugin default imports correctly in ES modules under TypeScript's node16 and nodenext resolution

v2.11.0 (OKLab and OKLCH)

Choose a tag to compare

@github-actions github-actions released this 08 Nov 22:50
a334cdc

Minor Changes

  • New oklab and oklch plugins to parse and convert OKLab and OKLCH colors (CSS Color 4)

v2.10.1

Choose a tag to compare

@github-actions github-actions released this 08 Nov 22:13
eeec21f

Patch Changes

  • Fix: Read the alpha byte of a HEX color exactly, so #cc88 no longer comes back as #cccc8887 ❀️ @spokodev
  • Fix: Stop minify from turning down an alpha hex that holds the color exactly, and from returning nothing at all when every notation is switched off

v2.10 (RGB color mixing)

Choose a tag to compare

@omgovich omgovich released this 20 Aug 16:59
b10c2f9
  • mix, tints, shades and tones (mix plugin) now accept an optional interpolation color space. LAB stays the default; pass "rgb" to interpolate RGB channels instead β€” the way browsers and design tools (such as Figma) composite translucent layers.
import { colord, extend } from "colord";
import mixPlugin from "colord/plugins/mix";

extend([mixPlugin]);

colord("#ff0000").mix("#ffffff", 0.5, "rgb").toHex(); // "#ff8080"
colord("#f0f3f1").mix("#007d40", 0.14, "rgb").toHex(); // "#cee2d8" β€” same as compositing rgba(0, 125, 64, 0.14) over #f0f3f1
colord("#ff0000").tints(3, "rgb").map((c) => c.toHex()); // ["#ff0000", "#ff8080", "#ffffff"]

v2.9 (πŸ—œ Color minification)

Choose a tag to compare

@omgovich omgovich released this 18 Oct 19:38
  • New minify plugin adding color string minification utilities.
import { colord, extend } from "colord";
import minifyPlugin from "colord/plugins/minify";

extend([minifyPlugin]);

colord("black").minify(); // "#000"
colord("#112233").minify(); // "#123"
colord("darkgray").minify(); // "#a9a9a9"
colord("rgba(170,170,170,0.4)").minify(); // "hsla(0,0%,67%,.4)"
colord("rgba(170,170,170,0.4)").minify({ alphaHex: true }); // "#aaa6"

v2.8 (Perceived color difference)

Choose a tag to compare

@omgovich omgovich released this 23 Sep 16:01
  • @EricRovell added delta method to calculate the perceived color difference (CIE Delta E 2000) between two colors. The return value is 0 if the colors are equal, 1 if they are entirely different.
colord("#faf0c8").delta("#ffffff"); // 0.148
colord("#3296fa").delta("#197dc8"); // 0.099
colord("#afafaf").delta("#b4b4b4"); // 0.014
colord("#000000").delta("#ffffff"); // 1

v2.7 (Tints, tones and shades)

Choose a tag to compare

@omgovich omgovich released this 27 Aug 15:22
  • @EricRovell added new tints, tones and shades methods to mix plugin.
const color = colord("#ff0000");
color.tints(3).map((c) => c.toHex());  // ["#ff0000", "#ff9f80", "#ffffff"];
color.shades(3).map((c) => c.toHex()); // ["#ff0000", "#7a1b0b", "#000000"];
color.tones(3).map((c) => c.toHex());  // ["#ff0000", "#c86147", "#808080"];

v2.4 (Color harmonies)

Choose a tag to compare

@omgovich omgovich released this 23 Jul 12:05
import { colord, extends } from "colord";
import harmoniesPlugin from "colord/plugins/harmonies";

extend([harmoniesPlugin]);

const color = colord("#ff0000");
color.harmonies("analogous").map((c) => c.toHex()); // ["#ff0080", "#ff0000", "#ff8000"]
color.harmonies("complementary").map((c) => c.toHex()); // ["#ff0000", "#00ffff"]
color.harmonies("rectangle").map((c) => c.toHex()); // ["#ff0000", "#ffff00", "#00ffff", "#0000ff"]
color.harmonies("split-complementary").map((c) => c.toHex()); // ["#ff0000", "#00ff80", "#0080ff"]
color.harmonies("tetradic").map((c) => c.toHex()); // ["#ff0000", "#80ff00", "#00ffff", "#8000ff"]
color.harmonies("triadic").map((c) => c.toHex()); // ["#ff0000", "#00ff00", "#0000ff"]