{"_id":"colord@2.10.0","bugs":{"url":"https://github.com/omgovich/colord/issues"},"dist":{"shasum":"56c9050e6b06b4b6c62ddec366a48d65ef57e860","tarball":"http://registry-npm.ywwl.com/colord/download/colord-2.10.0.tgz","fileCount":67,"integrity":"sha512-AidJptpBJmjTclAp9BkLwJi0T93fo5epJnbaZslpg6QVzpHjAiveF55mE9AcUJiGMqRHgMDY8soMsQtuNYMHfw==","signatures":[{"sig":"MEYCIQDXDhVlj2dM4b6ZtjCgT1FrvPhKqQDHGMvWCm3Kf3vE0wIhAI+F9aVc/MTkv6+C1UGDPcRlErDSx7Gv80zNQZCAjfeY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIENwfZumbyvKpNEV5VpwHZy3Nu2TTp55WQ4GFW6fUW/KAiB1SxgxIetoDjhjnb58t1JllvgRR3zzOiQ06Hz5cuKWBg=="}],"unpackedSize":126597,"size":36921,"noattachment":false,"key":"/colord/-/colord-2.10.0.tgz"},"jest":{"verbose":true,"transform":{"^.+\\.ts$":"ts-jest"}},"main":"./index.js","name":"colord","types":"index.d.ts","author":{"name":"Vlad Shilov","email":"omgovich@ya.ru"},"module":"./index.mjs","exports":{".":{"types":"./index.d.ts","import":"./index.mjs","default":"./index.mjs","require":"./index.js"},"./plugins/hwb":{"types":"./plugins/hwb.d.ts","import":"./plugins/hwb.mjs","default":"./plugins/hwb.mjs","require":"./plugins/hwb.js"},"./plugins/lab":{"types":"./plugins/lab.d.ts","import":"./plugins/lab.mjs","default":"./plugins/lab.mjs","require":"./plugins/lab.js"},"./plugins/lch":{"types":"./plugins/lch.d.ts","import":"./plugins/lch.mjs","default":"./plugins/lch.mjs","require":"./plugins/lch.js"},"./plugins/mix":{"types":"./plugins/mix.d.ts","import":"./plugins/mix.mjs","default":"./plugins/mix.mjs","require":"./plugins/mix.js"},"./plugins/xyz":{"types":"./plugins/xyz.d.ts","import":"./plugins/xyz.mjs","default":"./plugins/xyz.mjs","require":"./plugins/xyz.js"},"./package.json":"./package.json","./plugins/a11y":{"types":"./plugins/a11y.d.ts","import":"./plugins/a11y.mjs","default":"./plugins/a11y.mjs","require":"./plugins/a11y.js"},"./plugins/cmyk":{"types":"./plugins/cmyk.d.ts","import":"./plugins/cmyk.mjs","default":"./plugins/cmyk.mjs","require":"./plugins/cmyk.js"},"./plugins/names":{"types":"./plugins/names.d.ts","import":"./plugins/names.mjs","default":"./plugins/names.mjs","require":"./plugins/names.js"},"./plugins/minify":{"types":"./plugins/minify.d.ts","import":"./plugins/minify.mjs","default":"./plugins/minify.mjs","require":"./plugins/minify.js"},"./plugins/harmonies":{"types":"./plugins/harmonies.d.ts","import":"./plugins/harmonies.mjs","default":"./plugins/harmonies.mjs","require":"./plugins/harmonies.js"}},"gitHead":"b10c2f94457c3bc48af9533b555c308768465d51","license":"MIT","scripts":{"lint":"eslint src/**/*.ts","size":"npm run build && size-limit","test":"jest tests --coverage","build":"rm -rf ./dist/* && rollup --config","release":"npm run build && cp *.json dist && cp *.md dist && npm publish ./dist","benchmark":"tsc --outDir bench --skipLibCheck --esModuleInterop ./tests/benchmark.ts && node ./bench/tests/benchmark.js; code=$?; rm -rf ./bench; exit $code","check-types":"tsc --noEmit true","check-release":"npm run release -- --dry-run"},"version":"2.10.0","_npmUser":{"name":"omgovich","email":"omgovich@ya.ru"},"homepage":"https://github.com/omgovich/colord#readme","keywords":["color","parser","convert","tiny","hex","rgb","hsl","hsv","hwb","lab","lch","xyz","css","color-names","a11y","cmyk","mix","minify","harmonies"],"prettier":{"printWidth":100},"repository":{"url":"git+https://github.com/omgovich/colord.git","type":"git"},"size-limit":[{"path":"dist/index.mjs","limit":"2 KB","import":"{ colord }"},{"path":"dist/plugins/a11y.mjs","limit":"0.5 KB"},{"path":"dist/plugins/cmyk.mjs","limit":"1 KB"},{"path":"dist/plugins/harmonies.mjs","limit":"0.5 KB"},{"path":"dist/plugins/hwb.mjs","limit":"1 KB"},{"path":"dist/plugins/lab.mjs","limit":"1.5 KB"},{"path":"dist/plugins/lch.mjs","limit":"1.5 KB"},{"path":"dist/plugins/minify.mjs","limit":"0.6 KB"},{"path":"dist/plugins/mix.mjs","limit":"1.1 KB"},{"path":"dist/plugins/names.mjs","limit":"1.5 KB"},{"path":"dist/plugins/xyz.mjs","limit":"1 KB"}],"_npmVersion":"10.9.7","description":"👑 A tiny yet powerful tool for high-performance color manipulations and conversions","directories":{},"maintainers":[{"name":"omgovich","email":"omgovich@ya.ru"}],"sideEffects":false,"_nodeVersion":"22.22.2","eslintConfig":{"extends":["eslint:recommended","plugin:@typescript-eslint/eslint-recommended","plugin:@typescript-eslint/recommended","plugin:prettier/recommended","prettier/@typescript-eslint"],"plugins":["prettier"]},"_hasShrinkwrap":false,"devDependencies":{"glob":"^7.1.6","jest":"^26.6.3","benny":"^3.6.15","color":"^3.1.3","tslib":"^2.1.0","eslint":"^7.14.0","rollup":"^2.80.0","ts-jest":"^26.5.4","ts-node":"^9.1.1","prettier":"^2.2.0","ac-colors":"^1.4.2","chroma-js":"^2.1.1","size-limit":"^11.2.0","tinycolor2":"^1.4.2","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","eslint-config-prettier":"^6.15.0","eslint-plugin-prettier":"^3.1.4","@typescript-eslint/parser":"^4.19.0","rollup-plugin-typescript2":"^0.36.0","@size-limit/preset-small-lib":"^11.2.0","@typescript-eslint/eslint-plugin":"^4.19.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/colord_2.10.0_1787245798347_0.4389890521197306"},"readme":"<div align=\"center\">\n  <a href=\"https://colord.omgovich.ru/\">\n    <img src=\"assets/logo.png\" width=\"280\" height=\"210\" alt=\"colord\" />\n  </a>\n</div>\n\n<div align=\"center\">\n  <a href=\"https://npmjs.org/package/colord\">\n    <img alt=\"npm\" src=\"https://img.shields.io/npm/v/colord.svg?labelColor=dd3a5e&color=6ead0a\" />\n  </a>\n  <a href=\"https://codecov.io/gh/omgovich/colord\">\n    <img alt=\"coverage\" src=\"https://img.shields.io/codecov/c/github/omgovich/colord.svg?labelColor=dd3a5e&color=6ead0a\" />\n  </a>\n  <a href=\"https://npmjs.org/package/colord\">\n    <img alt=\"no dependencies\" src=\"https://img.shields.io/badge/dependencies-0-6ead0a?labelColor=dd3a5e\" />\n  </a>\n  <a href=\"https://npmjs.org/package/colord\">\n    <img alt=\"types included\" src=\"https://badgen.net/npm/types/colord?labelColor=dd3a5e&color=6ead0a\" />\n  </a>\n</div>\n\n<div align=\"center\">\n  <strong>Colord</strong> is a tiny yet powerful tool for high-performance color manipulations and conversions.\n</div>\n\n## Features\n\n- 📦 **Small**: Just **1.8 KB** brotlied ([4x+ lighter](#benchmarks) than **color**)\n- 🚀 **Fast**: [5.5x+ faster](#benchmarks) than **color**\n- 😍 **Simple**: Chainable API and familiar patterns\n- 💪 **Immutable**: No need to worry about data mutations\n- 🛡 **Bulletproof**: Written in strict TypeScript and has 100% test coverage\n- 🗂 **Typed**: Ships with [types included](#types)\n- 🏗 **Extendable**: Built-in [plugin system](#plugins) to add new functionality\n- 📚 **CSS-compliant**: Strictly follows CSS Color Level specifications\n- 👫 **Works everywhere**: Supports all browsers and Node.js\n- 💨 **Dependency-free**\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Benchmarks\n\n| Library                      | <nobr>Operations/sec</nobr>   | Size<br /> (minified) | Size<br /> (brotlied) | Type declarations                                                                                        |\n| ---------------------------- | ----------------------------- | --------------------- | --------------------- | -------------------------------------------------------------------------------------------------------- |\n| <nobr><b>colord 👑</b></nobr> | <nobr><b>4,740,298</b></nobr> | <b>5.81 kB</b>        | <b>1.80 kB</b>        | [![](https://badgen.net/npm/types/colord?color=6ead0a&label=)](https://npmjs.com/package/colord)         |\n| color                        | 815,693                       | 24 kB                 | 7.52 kB               | [![](https://badgen.net/npm/types/color?color=6ead0a&label=)](https://npmjs.com/package/color)           |\n| tinycolor2                   | 1,012,855                     | 15.23 kB              | 4.67 kB               | [![](https://badgen.net/npm/types/tinycolor2?color=e6591d&label=)](https://npmjs.com/package/tinycolor2) |\n| ac-colors                    | 973,255                       | 10.18 kB              | 2.96 kB               | [![](https://badgen.net/npm/types/ac-colors?color=red&label=)](https://npmjs.com/package/ac-colors)      |\n| chroma-js                    | 951,018                       | 42.47 kB              | 14.89 kB              | [![](https://badgen.net/npm/types/chroma-js?color=e6591d&label=)](https://npmjs.com/package/chroma-js)   |\n\nMeasured by the [Benchmark workflow](https://github.com/omgovich/colord/actions/workflows/benchmark.yml) on a standard GitHub-hosted runner (Ubuntu 24.04, 4 vCPU, Node 22). Ops/sec depend on the machine, so read the ratios rather than the absolute numbers. Bundle sizes come from [size-limit](https://github.com/ai/size-limit), importing each library's main export so unused code is tree-shaken away, the same way `npm run size` measures colord.\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Who Uses Colord\n\n| Project                                                 | What it is                                                    | Reach                             |\n| ------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------- |\n| **[GitLab](https://gitlab.com/gitlab-org/gitlab)**      | DevSecOps for the entire software lifecycle                   | <nobr>50M+ users</nobr>           |\n| **[WordPress](https://github.com/WordPress/gutenberg)** | Gutenberg, the editor inside every WordPress site             | <nobr>40% of all websites</nobr>  |\n| **[Stylelint](https://github.com/stylelint/stylelint)** | A mighty CSS linter                                           | <nobr>44M downloads/month</nobr>  |\n| **[cssnano](https://github.com/cssnano/cssnano)**       | The CSS minifier of the PostCSS world <nobr>(up to v6)</nobr> | <nobr>48M downloads/month</nobr>  |\n| **[pdf.net](https://pdf.net/)**                         | Everything you can do to a PDF, in the browser                | <nobr>4M+ users</nobr>            |\n| **[Gitea](https://github.com/go-gitea/gitea)**          | Self-hosted all-in-one software development service           | <nobr>57.5k ⭐</nobr>              |\n| **[PixiJS](https://github.com/pixijs/pixijs)**          | The fastest, most flexible 2D WebGL renderer                  | <nobr>48k ⭐</nobr>                |\n| **[Umami](https://github.com/umami-software/umami)**    | Analytics without the surveillance                            | <nobr>38k ⭐</nobr>                |\n| **[Documenso](https://github.com/documenso/documenso)** | The open source DocuSign                                      | <nobr>14.6k ⭐</nobr>              |\n| **[Leva](https://github.com/pmndrs/leva)**              | React-first GUI panel for live tweaking                       | <nobr>3.5M downloads/month</nobr> |\n\n...and [9.5 million more repositories](https://github.com/omgovich/colord/network/dependents) 🤯\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Getting Started\n\n```\nnpm i colord\n```\n\n```js\nimport { colord } from \"colord\";\n\ncolord(\"#ff0000\").grayscale().alpha(0.25).toRgbString(); // \"rgba(128, 128, 128, 0.25)\"\ncolord(\"rgb(192, 192, 192)\").isLight(); // true\ncolord(\"hsl(0, 50%, 50%)\").darken(0.25).toHex(); // \"#602020\"\n```\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Supported Color Models\n\n- Hexadecimal strings (including 3, 4 and 8 digit notations)\n- RGB strings and objects\n- HSL strings and objects\n- HSV objects\n- Color names ([via plugin](#plugins))\n- HWB objects and strings ([via plugin](#plugins))\n- CMYK objects and strings ([via plugin](#plugins))\n- LCH objects and strings ([via plugin](#plugins))\n- LAB objects ([via plugin](#plugins))\n- XYZ objects ([via plugin](#plugins))\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## API\n\n### Color parsing\n\n<details>\n  <summary><b><code>colord(input)</code></b></summary>\n\nParses the given input and creates a new Colord instance. String parsing strictly conforms to [CSS Color Level Specifications](https://www.w3.org/TR/css-color-4/#color-type).\n\n```js\nimport { colord } from \"colord\";\n\n// String input examples\ncolord(\"#FFF\");\ncolord(\"#ffffff\");\ncolord(\"#ffffffff\");\ncolord(\"rgb(255, 255, 255)\");\ncolord(\"rgba(255, 255, 255, 0.5)\");\ncolord(\"rgba(100% 100% 100% / 50%)\");\ncolord(\"hsl(90, 100%, 100%)\");\ncolord(\"hsla(90, 100%, 100%, 0.5)\");\ncolord(\"hsla(90deg 100% 100% / 50%)\");\ncolord(\"tomato\"); // requires \"names\" plugin\n\n// Object input examples\ncolord({ r: 255, g: 255, b: 255 });\ncolord({ r: 255, g: 255, b: 255, a: 1 });\ncolord({ h: 360, s: 100, l: 100 });\ncolord({ h: 360, s: 100, l: 100, a: 1 });\ncolord({ h: 360, s: 100, v: 100 });\ncolord({ h: 360, s: 100, v: 100, a: 1 });\n```\n\nCheck out the [\"Plugins\"](#plugins) section for more input format examples.\n\n</details>\n\n<details>\n  <summary><b><code>getFormat(input)</code></b></summary>\n\nReturns a color model name for the input passed to the function. Uses the same parsing system as `colord` function.\n\n```js\nimport { getFormat } from \"colord\";\n\ngetFormat(\"#aabbcc\"); // \"hex\"\ngetFormat({ r: 13, g: 237, b: 162, a: 0.5 }); // \"rgb\"\ngetFormat(\"hsl(180deg, 50%, 50%)\"); // \"hsl\"\ngetFormat(\"WUT?\"); // undefined\n```\n\n</details>\n\n### Color conversion\n\n<details>\n  <summary><b><code>.toHex()</code></b></summary>\n\nReturns the [hexadecimal representation](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgb_colors) of a color. When the alpha channel value of the color is less than 1, it outputs `#rrggbbaa` format instead of `#rrggbb`.\n\n```js\ncolord(\"rgb(0, 255, 0)\").toHex(); // \"#00ff00\"\ncolord({ h: 300, s: 100, l: 50 }).toHex(); // \"#ff00ff\"\ncolord({ r: 255, g: 255, b: 255, a: 0 }).toHex(); // \"#ffffff00\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toRgb()</code></b></summary>\n\n```js\ncolord(\"#ff0000\").toRgb(); // { r: 255, g: 0, b: 0, a: 1 }\ncolord({ h: 180, s: 100, l: 50, a: 0.5 }).toRgb(); // { r: 0, g: 255, b: 255, a: 0.5 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toRgbString()</code></b></summary>\n\n```js\ncolord(\"#ff0000\").toRgbString(); // \"rgb(255, 0, 0)\"\ncolord({ h: 180, s: 100, l: 50, a: 0.5 }).toRgbString(); // \"rgba(0, 255, 255, 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toHsl()</code></b></summary>\n\nConverts a color to [HSL color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object.\n\n```js\ncolord(\"#ffff00\").toHsl(); // { h: 60, s: 100, l: 50, a: 1 }\ncolord(\"rgba(0, 0, 255, 0.5) \").toHsl(); // { h: 240, s: 100, l: 50, a: 0.5 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toHslString()</code></b></summary>\n\nConverts a color to [HSL color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and expresses it through the [functional notation](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#hsl_colors).\n\n```js\ncolord(\"#ffff00\").toHslString(); // \"hsl(60, 100%, 50%)\"\ncolord(\"rgba(0, 0, 255, 0.5)\").toHslString(); // \"hsla(240, 100%, 50%, 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toHsv()</code></b></summary>\n\nConverts a color to [HSV color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object.\n\n```js\ncolord(\"#ffff00\").toHsv(); // { h: 60, s: 100, v: 100, a: 1 }\ncolord(\"rgba(0, 255, 255, 0.5) \").toHsv(); // { h: 180, s: 100, v: 100, a: 1 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toName(options?)</code></b> (<b>names</b> plugin)</summary>\n\nConverts a color to a [CSS keyword](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords). Returns `undefined` if the color is not specified in the specs.\n\n```js\nimport { colord, extend } from \"colord\";\nimport namesPlugin from \"colord/plugins/names\";\n\nextend([namesPlugin]);\n\ncolord(\"#ff6347\").toName(); // \"tomato\"\ncolord(\"#00ffff\").toName(); // \"cyan\"\ncolord(\"rgba(0, 0, 0, 0)\").toName(); // \"transparent\"\n\ncolord(\"#fe0000\").toName(); // undefined (the color is not specified in CSS specs)\ncolord(\"#fe0000\").toName({ closest: true }); // \"red\" (closest color available)\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toCmyk()</code></b> (<b>cmyk</b> plugin)</summary>\n\nConverts a color to [CMYK](https://en.wikipedia.org/wiki/CMYK_color_model) color space.\n\n```js\nimport { colord, extend } from \"colord\";\nimport cmykPlugin from \"colord/plugins/cmyk\";\n\nextend([cmykPlugin]);\n\ncolord(\"#ffffff\").toCmyk(); // { c: 0, m: 0, y: 0, k: 0, a: 1 }\ncolord(\"#555aaa\").toCmyk(); // { c: 50, m: 47, y: 0, k: 33, a: 1 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toCmykString()</code></b> (<b>cmyk</b> plugin)</summary>\n\nConverts a color to color space.\n\nConverts a color to [CMYK](https://en.wikipedia.org/wiki/CMYK_color_model) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#device-cmyk)\n\n```js\nimport { colord, extend } from \"colord\";\nimport cmykPlugin from \"colord/plugins/cmyk\";\n\nextend([cmykPlugin]);\n\ncolord(\"#99ffff\").toCmykString(); // \"device-cmyk(40% 0% 0% 0%)\"\ncolord(\"#00336680\").toCmykString(); // \"device-cmyk(100% 50% 0% 60% / 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toHwb()</code></b> (<b>hwb</b> plugin)</summary>\n\nConverts a color to [HWB (Hue-Whiteness-Blackness)](https://en.wikipedia.org/wiki/HWB_color_model) color space.\n\n```js\nimport { colord, extend } from \"colord\";\nimport hwbPlugin from \"colord/plugins/hwb\";\n\nextend([hwbPlugin]);\n\ncolord(\"#ffffff\").toHwb(); // { h: 0, w: 100, b: 0, a: 1 }\ncolord(\"#555aaa\").toHwb(); // { h: 236, w: 33, b: 33, a: 1 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toHwbString()</code></b> (<b>hwb</b> plugin)</summary>\n\nConverts a color to [HWB (Hue-Whiteness-Blackness)](https://en.wikipedia.org/wiki/HWB_color_model) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#the-hwb-notation).\n\n```js\nimport { colord, extend } from \"colord\";\nimport hwbPlugin from \"colord/plugins/hwb\";\n\nextend([hwbPlugin]);\n\ncolord(\"#999966\").toHwbString(); // \"hwb(60 40% 40%)\"\ncolord(\"#99ffff\").toHwbString(); // \"hwb(180 60% 0%)\"\ncolord(\"#003366\").alpha(0.5).toHwbString(); // \"hwb(210 0% 60% / 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toLab()</code></b> (<b>lab</b> plugin)</summary>\n\nConverts a color to [CIE LAB](https://en.wikipedia.org/wiki/CIELAB_color_space) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\n```js\nimport { colord, extend } from \"colord\";\nimport labPlugin from \"colord/plugins/lab\";\n\nextend([labPlugin]);\n\ncolord(\"#ffffff\").toLab(); // { l: 100, a: 0, b: 0, alpha: 1 }\ncolord(\"#33221180\").toLab(); // { l: 14.89, a: 5.77, b: 14.41, alpha: 0.5 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toLch()</code></b> (<b>lch</b> plugin)</summary>\n\nConverts a color to [CIE LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\n```js\nimport { colord, extend } from \"colord\";\nimport lchPlugin from \"colord/plugins/lch\";\n\nextend([lchPlugin]);\n\ncolord(\"#ffffff\").toLch(); // { l: 100, c: 0, h: 0, a: 1 }\ncolord(\"#213b0b\").toLch(); // { l: 21.85, c: 31.95, h: 127.77, a: 1 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toLchString()</code></b> (<b>lch</b> plugin)</summary>\n\nConverts a color to [CIE LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#specifying-lab-lch).\n\n```js\nimport { colord, extend } from \"colord\";\nimport lchPlugin from \"colord/plugins/lch\";\n\nextend([lchPlugin]);\n\ncolord(\"#ffffff\").toLchString(); // \"lch(100% 0 0)\"\ncolord(\"#213b0b\").alpha(0.5).toLchString(); // \"lch(21.85% 31.95 127.77 / 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.toXyz()</code></b> (<b>xyz</b> plugin)</summary>\n\nConverts a color to [CIE XYZ](https://www.sttmedia.com/colormodel-xyz) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\n```js\nimport { colord, extend } from \"colord\";\nimport xyzPlugin from \"colord/plugins/xyz\";\n\nextend([xyzPlugin]);\n\ncolord(\"#ffffff\").toXyz(); // { x: 95.047, y: 100, z: 108.883, a: 1 }\n```\n\n</details>\n\n### Color manipulation\n\n<details>\n  <summary><b><code>.alpha(value)</code></b></summary>\n\nChanges the alpha channel value and returns a new `Colord` instance.\n\n```js\ncolord(\"rgb(0, 0, 0)\").alpha(0.5).toRgbString(); // \"rgba(0, 0, 0, 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.invert()</code></b></summary>\n\nCreates a new `Colord` instance containing an inverted (opposite) version of the color.\n\n```js\ncolord(\"#ffffff\").invert().toHex(); // \"#000000\"\ncolord(\"#aabbcc\").invert().toHex(); // \"#554433\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.saturate(amount = 0.1)</code></b></summary>\n\nIncreases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount.\n\n```js\ncolord(\"#bf4040\").saturate(0.25).toHex(); // \"#df2020\"\ncolord(\"hsl(0, 50%, 50%)\").saturate(0.5).toHslString(); // \"hsl(0, 100%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.desaturate(amount = 0.1)</code></b></summary>\n\nDecreases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount.\n\n```js\ncolord(\"#df2020\").desaturate(0.25).toHex(); // \"#bf4040\"\ncolord(\"hsl(0, 100%, 50%)\").desaturate(0.5).toHslString(); // \"hsl(0, 50%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.grayscale()</code></b></summary>\n\nMakes a gray color with the same lightness as a source color. Same as calling `desaturate(1)`.\n\n```js\ncolord(\"#bf4040\").grayscale().toHex(); // \"#808080\"\ncolord(\"hsl(0, 100%, 50%)\").grayscale().toHslString(); // \"hsl(0, 0%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.lighten(amount = 0.1)</code></b></summary>\n\nIncreases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount.\n\n```js\ncolord(\"#000000\").lighten(0.5).toHex(); // \"#808080\"\ncolord(\"#223344\").lighten(0.3).toHex(); // \"#5580aa\"\ncolord(\"hsl(0, 50%, 50%)\").lighten(0.5).toHslString(); // \"hsl(0, 50%, 100%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.darken(amount = 0.1)</code></b></summary>\n\nDecreases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount.\n\n```js\ncolord(\"#ffffff\").darken(0.5).toHex(); // \"#808080\"\ncolord(\"#5580aa\").darken(0.3).toHex(); // \"#223344\"\ncolord(\"hsl(0, 50%, 100%)\").lighten(0.5).toHslString(); // \"hsl(0, 50%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.hue(value)</code></b></summary>\n\nChanges the hue value and returns a new `Colord` instance.\n\n```js\ncolord(\"hsl(90, 50%, 50%)\").hue(180).toHslString(); // \"hsl(180, 50%, 50%)\"\ncolord(\"hsl(90, 50%, 50%)\").hue(370).toHslString(); // \"hsl(10, 50%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.rotate(amount = 15)</code></b></summary>\n\nIncreases the [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV) hue value of a color by the given amount.\n\n```js\ncolord(\"hsl(90, 50%, 50%)\").rotate(90).toHslString(); // \"hsl(180, 50%, 50%)\"\ncolord(\"hsl(90, 50%, 50%)\").rotate(-180).toHslString(); // \"hsl(270, 50%, 50%)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.mix(color2, ratio = 0.5, space = \"lab\")</code></b> (<b>mix</b> plugin)</summary>\n\nProduces a mixture of two colors and returns the result of mixing them (new Colord instance).\n\nIn contrast to other libraries that perform RGB values mixing, Colord mixes colors through [LAB color space](https://en.wikipedia.org/wiki/CIELAB_color_space) by default. This approach produces better results and doesn't have the drawbacks the legacy way has.\n\nPass `\"rgb\"` as the third argument to interpolate RGB channels instead. This mode matches the way browsers and design tools (such as Figma) composite translucent layers: mixing a background with an overlay color at the overlay's opacity gives the same result as alpha compositing.\n\n→ [Online demo](https://3cg7o.csb.app/)\n\n```js\nimport { colord, extend } from \"colord\";\nimport mixPlugin from \"colord/plugins/mix\";\n\nextend([mixPlugin]);\n\ncolord(\"#ffffff\").mix(\"#000000\").toHex(); // \"#777777\"\ncolord(\"#800080\").mix(\"#dda0dd\").toHex(); // \"#af5cae\"\ncolord(\"#cd853f\").mix(\"#eee8aa\", 0.6).toHex(); // \"#e3c07e\"\ncolord(\"#008080\").mix(\"#808000\", 0.35).toHex(); // \"#50805d\"\n\n// RGB interpolation (matches alpha compositing in browsers and design tools)\ncolord(\"#ff0000\").mix(\"#ffffff\", 0.5, \"rgb\").toHex(); // \"#ff8080\"\ncolord(\"#f0f3f1\").mix(\"#007d40\", 0.14, \"rgb\").toHex(); // \"#cee2d8\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>.tints(count = 5, space = \"lab\")</code></b> (<b>mix</b> plugin)</summary>\n\nProvides functionality to generate [tints](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. Mixes through LAB color space by default; pass `\"rgb\"` to interpolate RGB channels instead.\n\n```js\nimport { colord, extend } from \"colord\";\nimport mixPlugin from \"colord/plugins/mix\";\n\nextend([mixPlugin]);\n\nconst color = colord(\"#ff0000\");\ncolor.tints(3).map((c) => c.toHex()); // [\"#ff0000\", \"#ff9f80\", \"#ffffff\"];\n```\n\n</details>\n\n<details>\n  <summary><b><code>.shades(count = 5, space = \"lab\")</code></b> (<b>mix</b> plugin)</summary>\n\nProvides functionality to generate [shades](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. Mixes through LAB color space by default; pass `\"rgb\"` to interpolate RGB channels instead.\n\n```js\nimport { colord, extend } from \"colord\";\nimport mixPlugin from \"colord/plugins/mix\";\n\nextend([mixPlugin]);\n\nconst color = colord(\"#ff0000\");\ncolor.shades(3).map((c) => c.toHex()); // [\"#ff0000\", \"#7a1b0b\", \"#000000\"];\n```\n\n</details>\n\n<details>\n  <summary><b><code>.tones(count = 5, space = \"lab\")</code></b> (<b>mix</b> plugin)</summary>\n\nProvides functionality to generate [tones](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. Mixes through LAB color space by default; pass `\"rgb\"` to interpolate RGB channels instead.\n\n```js\nimport { colord, extend } from \"colord\";\nimport mixPlugin from \"colord/plugins/mix\";\n\nextend([mixPlugin]);\n\nconst color = colord(\"#ff0000\");\ncolor.tones(3).map((c) => c.toHex()); // [\"#ff0000\", \"#c86147\", \"#808080\"];\n```\n\n</details>\n\n<details>\n  <summary><b><code>.harmonies(type = \"complementary\")</code></b> (<b>harmonies</b> plugin)</summary>\n\nProvides functionality to generate [harmony colors](<https://en.wikipedia.org/wiki/Harmony_(color)>). Returns an array of `Colord` instances.\n\n```js\nimport { colord, extend } from \"colord\";\nimport harmoniesPlugin from \"colord/plugins/harmonies\";\n\nextend([harmoniesPlugin]);\n\nconst color = colord(\"#ff0000\");\ncolor.harmonies(\"analogous\").map((c) => c.toHex()); // [\"#ff0080\", \"#ff0000\", \"#ff8000\"]\ncolor.harmonies(\"complementary\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ffff\"]\ncolor.harmonies(\"double-split-complementary\").map((c) => c.toHex()); // [\"#ff0080\", \"#ff0000\", \"#ff8000\", \"#00ff80\", \"#0080ff\"]\ncolor.harmonies(\"rectangle\").map((c) => c.toHex()); // [\"#ff0000\", \"#ffff00\", \"#00ffff\", \"#0000ff\"]\ncolor.harmonies(\"split-complementary\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ff80\", \"#0080ff\"]\ncolor.harmonies(\"tetradic\").map((c) => c.toHex()); // [\"#ff0000\", \"#80ff00\", \"#00ffff\", \"#8000ff\"]\ncolor.harmonies(\"triadic\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ff00\", \"#0000ff\"]\n```\n\n</details>\n\n### Color analysis\n\n<details>\n  <summary><b><code>.isValid()</code></b></summary>\n\nReturns a boolean indicating whether or not an input has been parsed successfully.\nNote: If parsing is unsuccessful, Colord defaults to black (does not throws an error).\n\n```js\ncolord(\"#ffffff\").isValid(); // true\ncolord(\"#wwuutt\").isValid(); // false\ncolord(\"abracadabra\").isValid(); // false\ncolord({ r: 0, g: 0, b: 0 }).isValid(); // true\ncolord({ r: 0, g: 0, v: 0 }).isValid(); // false\n```\n\n</details>\n\n<details>\n  <summary><b><code>.isEqual(color2)</code></b></summary>\n\nDetermines whether two values are the same color.\n\n```js\ncolord(\"#000000\").isEqual(\"rgb(0, 0, 0)\"); // true\ncolord(\"#000000\").isEqual(\"rgb(255, 255, 255)\"); // false\n```\n\n</details>\n\n<details>\n  <summary><b><code>.alpha()</code></b></summary>\n\n```js\ncolord(\"#ffffff\").alpha(); // 1\ncolord(\"rgba(50, 100, 150, 0.5)\").alpha(); // 0.5\n```\n\n</details>\n\n<details>\n  <summary><b><code>.hue()</code></b></summary>\n\n```js\ncolord(\"hsl(90, 50%, 50%)\").hue(); // 90\ncolord(\"hsl(-10, 50%, 50%)\").hue(); // 350\n```\n\n</details>\n\n<details>\n  <summary><b><code>.brightness()</code></b></summary>\n\nReturns the brightness of a color (from 0 to 1). The calculation logic is modified from [Web Content Accessibility Guidelines](https://www.w3.org/TR/AERT/#color-contrast).\n\n```js\ncolord(\"#000000\").brightness(); // 0\ncolord(\"#808080\").brightness(); // 0.5\ncolord(\"#ffffff\").brightness(); // 1\n```\n\n</details>\n\n<details>\n  <summary><b><code>.isLight()</code></b></summary>\n\nSame as calling `brightness() >= 0.5`.\n\n```js\ncolord(\"#111111\").isLight(); // false\ncolord(\"#aabbcc\").isLight(); // true\ncolord(\"#ffffff\").isLight(); // true\n```\n\n</details>\n\n<details>\n  <summary><b><code>.isDark()</code></b></summary>\n\nSame as calling `brightness() < 0.5`.\n\n```js\ncolord(\"#111111\").isDark(); // true\ncolord(\"#aabbcc\").isDark(); // false\ncolord(\"#ffffff\").isDark(); // false\n```\n\n</details>\n\n<details>\n  <summary><b><code>.luminance()</code></b> (<b>a11y</b> plugin)</summary>\n\nReturns the relative luminance of a color, normalized to 0 for darkest black and 1 for lightest white as defined by [WCAG 2.0](https://www.w3.org/TR/WCAG20/#relativeluminancedef).\n\n```js\ncolord(\"#000000\").luminance(); // 0\ncolord(\"#808080\").luminance(); // 0.22\ncolord(\"#ccddee\").luminance(); // 0.71\ncolord(\"#ffffff\").luminance(); // 1\n```\n\n</details>\n\n<details>\n  <summary><b><code>.contrast(color2 = \"#FFF\")</code></b> (<b>a11y</b> plugin)</summary>\n\nCalculates a contrast ratio for a color pair. This luminance difference is expressed as a ratio ranging from 1 (e.g. white on white) to 21 (e.g., black on a white). [WCAG Accessibility Level AA requires](https://webaim.org/articles/contrast/) a ratio of at least 4.5 for normal text and 3 for large text.\n\n```js\ncolord(\"#000000\").contrast(); // 21 (black on white)\ncolord(\"#ffffff\").contrast(\"#000000\"); // 21 (white on black)\ncolord(\"#777777\").contrast(); // 4.47 (gray on white)\ncolord(\"#ff0000\").contrast(); // 3.99 (red on white)\ncolord(\"#0000ff\").contrast(\"#ff000\"); // 2.14 (blue on red)\n```\n\n</details>\n\n<details>\n  <summary><b><code>.isReadable(color2 = \"#FFF\", options?)</code></b> (<b>a11y</b> plugin)</summary>\n\nChecks that a background and text color pair is readable according to [WCAG 2.0 Contrast and Color Requirements](https://webaim.org/articles/contrast/).\n\n```js\ncolord(\"#000000\").isReadable(); // true (normal black text on white bg conforms to WCAG AA)\ncolord(\"#777777\").isReadable(); // false (normal gray text on white bg conforms to WCAG AA)\ncolord(\"#ffffff\").isReadable(\"#000000\"); // true (normal white text on black bg conforms to WCAG AA)\ncolord(\"#e60000\").isReadable(\"#ffff47\"); // true (normal red text on yellow bg conforms to WCAG AA)\ncolord(\"#e60000\").isReadable(\"#ffff47\", { level: \"AAA\" }); // false (normal red text on yellow bg does not conform to WCAG AAA)\ncolord(\"#e60000\").isReadable(\"#ffff47\", { level: \"AAA\", size: \"large\" }); // true (large red text on yellow bg conforms to WCAG AAA)\n```\n\n</details>\n\n<details>\n  <summary><b><code>.delta(color2 = \"#FFF\")</code></b> (<b>lab</b> plugin)</summary>\n\nCalculates the perceived color difference between two colors.\nThe difference calculated according to [Delta E2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000).\nThe return value is `0` if the colors are equal, `1` if they are entirely different.\n\n```js\ncolord(\"#3296fa\").delta(\"#197dc8\"); // 0.099\ncolord(\"#faf0c8\").delta(\"#ffffff\"); // 0.148\ncolord(\"#afafaf\").delta(\"#b4b4b4\"); // 0.014\ncolord(\"#000000\").delta(\"#ffffff\"); // 1\n```\n\n</details>\n\n### Color utilities\n\n<details>\n  <summary><b><code>random()</code></b></summary>\n\nReturns a new Colord instance with a random color value inside.\n\n```js\nimport { random } from \"colord\";\n\nrandom().toHex(); // \"#01c8ec\"\nrandom().alpha(0.5).toRgb(); // { r: 13, g: 237, b: 162, a: 0.5 }\n```\n\n</details>\n\n<details>\n  <summary><b><code>.minify(options?)</code></b></summary>\n\nConverts a color to its shortest string representation.\n\n```js\nimport { colord, extend } from \"colord\";\nimport minifyPlugin from \"colord/plugins/minify\";\n\nextend([minifyPlugin]);\n\ncolord(\"black\").minify(); // \"#000\"\ncolord(\"#112233\").minify(); // \"#123\"\ncolord(\"darkgray\").minify(); // \"#a9a9a9\"\ncolord(\"rgba(170,170,170,0.4)\").minify(); // \"hsla(0,0%,67%,.4)\"\ncolord(\"rgba(170,170,170,0.4)\").minify({ alphaHex: true }); // \"#aaa6\"\n```\n\n| Option        | Default | Description                                                  |\n| ------------- | ------- | ------------------------------------------------------------ |\n| `hex`         | `true`  | Enable `#rrggbb` and `#rgb` notations                        |\n| `alphaHex`    | `false` | Enable `#rrggbbaa` and `#rgba` notations                     |\n| `rgb`         | `true`  | Enable `rgb()` and `rgba()` functional notations             |\n| `hsl`         | `true`  | Enable `hsl()` and `hsla()` functional notations             |\n| `name`        | `false` | Enable CSS color keywords. Requires `names` plugin installed |\n| `transparent` | `false` | Enable `\"transparent\"` color keyword                         |\n\n</details>\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Plugins\n\n**Colord** has a built-in plugin system that allows new features and functionality to be easily added.\n\n<details>\n  <summary><b><code>a11y</code> (Accessibility)</b> <i>0.38 KB</i></summary>\n\nAdds accessibility and color contrast utilities working according to [Web Content Accessibility Guidelines 2.0](https://www.w3.org/TR/WCAG20/).\n\n```js\nimport { colord, extend } from \"colord\";\nimport a11yPlugin from \"colord/plugins/a11y\";\n\nextend([a11yPlugin]);\n\ncolord(\"#000000\").luminance(); // 0\ncolord(\"#ccddee\").luminance(); // 0.71\ncolord(\"#ffffff\").luminance(); // 1\n\ncolord(\"#000000\").contrast(); // 21 (black on white)\ncolord(\"#ffffff\").contrast(\"#000000\"); // 21 (white on black)\ncolord(\"#0000ff\").contrast(\"#ff000\"); // 2.14 (blue on red)\n\ncolord(\"#000000\").isReadable(); // true (black on white)\ncolord(\"#ffffff\").isReadable(\"#000000\"); // true (white on black)\ncolord(\"#777777\").isReadable(); // false (gray on white)\ncolord(\"#e60000\").isReadable(\"#ffff47\"); // true (normal red text on yellow bg conforms to WCAG AA)\ncolord(\"#e60000\").isReadable(\"#ffff47\", { level: \"AAA\" }); // false (normal red text on yellow bg does not conform to WCAG AAA)\ncolord(\"#e60000\").isReadable(\"#ffff47\", { level: \"AAA\", size: \"large\" }); // true (large red text on yellow bg conforms to WCAG AAA)\n```\n\n</details>\n\n<details>\n  <summary><b><code>cmyk</code> (CMYK color space)</b> <i>0.6 KB</i></summary>\n\nAdds support of [CMYK](https://www.sttmedia.com/colormodel-cmyk) color model.\n\n```js\nimport { colord, extend } from \"colord\";\nimport cmykPlugin from \"colord/plugins/cmyk\";\n\nextend([cmykPlugin]);\n\ncolord(\"#ffffff\").toCmyk(); // { c: 0, m: 0, y: 0, k: 0, a: 1 }\ncolord(\"#999966\").toCmykString(); // \"device-cmyk(0% 0% 33% 40%)\"\ncolord({ c: 0, m: 0, y: 0, k: 100, a: 1 }).toHex(); // \"#000000\"\ncolord(\"device-cmyk(0% 61% 72% 0% / 50%)\").toHex(); // \"#ff634780\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>harmonies</code> (Color harmonies)</b> <i>0.15 KB</i></summary>\n\nProvides functionality to generate [harmony colors](<https://en.wikipedia.org/wiki/Harmony_(color)>).\n\n```js\nimport { colord, extend } from \"colord\";\nimport harmonies from \"colord/plugins/harmonies\";\n\nextend([harmonies]);\n\nconst color = colord(\"#ff0000\");\ncolor.harmonies(\"analogous\").map((c) => c.toHex()); // [\"#ff0080\", \"#ff0000\", \"#ff8000\"]\ncolor.harmonies(\"complementary\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ffff\"]\ncolor.harmonies(\"double-split-complementary\").map((c) => c.toHex()); // [\"#ff0080\", \"#ff0000\", \"#ff8000\", \"#00ff80\", \"#0080ff\"]\ncolor.harmonies(\"rectangle\").map((c) => c.toHex()); // [\"#ff0000\", \"#ffff00\", \"#00ffff\", \"#0000ff\"]\ncolor.harmonies(\"split-complementary\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ff80\", \"#0080ff\"]\ncolor.harmonies(\"tetradic\").map((c) => c.toHex()); // [\"#ff0000\", \"#80ff00\", \"#00ffff\", \"#8000ff\"]\ncolor.harmonies(\"triadic\").map((c) => c.toHex()); // [\"#ff0000\", \"#00ff00\", \"#0000ff\"]\n```\n\n</details>\n\n<details>\n  <summary><b><code>hwb</code> (HWB color model)</b> <i>0.8 KB</i></summary>\n\nAdds support of [Hue-Whiteness-Blackness](https://en.wikipedia.org/wiki/HWB_color_model) color model.\n\n```js\nimport { colord, extend } from \"colord\";\nimport hwbPlugin from \"colord/plugins/hwb\";\n\nextend([hwbPlugin]);\n\ncolord(\"#999966\").toHwb(); // { h: 60, w: 40, b: 40, a: 1 }\ncolord(\"#003366\").toHwbString(); // \"hwb(210 0% 60%)\"\n\ncolord({ h: 60, w: 40, b: 40 }).toHex(); // \"#999966\"\ncolord(\"hwb(210 0% 60% / 50%)\").toHex(); // \"#00336680\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>lab</code> (CIE LAB color space)</b> <i>1.4 KB</i></summary>\n\nAdds support of [CIE LAB](https://en.wikipedia.org/wiki/CIELAB_color_space) color model. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\nAlso plugin provides `.delta` method for [perceived color difference calculations](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000).\n\n```js\nimport { colord, extend } from \"colord\";\nimport labPlugin from \"colord/plugins/lab\";\n\nextend([labPlugin]);\n\ncolord({ l: 53.24, a: 80.09, b: 67.2 }).toHex(); // \"#ff0000\"\ncolord(\"#ffffff\").toLab(); // { l: 100, a: 0, b: 0, alpha: 1 }\n\ncolord(\"#afafaf\").delta(\"#b4b4b4\"); // 0.014\ncolord(\"#000000\").delta(\"#ffffff\"); // 1\n```\n\n</details>\n\n<details>\n  <summary><b><code>lch</code> (CIE LCH color space)</b> <i>1.3 KB</i></summary>\n\nAdds support of [CIE LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\n```js\nimport { colord, extend } from \"colord\";\nimport lchPlugin from \"colord/plugins/lch\";\n\nextend([lchPlugin]);\n\ncolord({ l: 100, c: 0, h: 0 }).toHex(); // \"#ffffff\"\ncolord(\"lch(48.25% 30.07 196.38)\").toHex(); // \"#008080\"\n\ncolord(\"#646464\").toLch(); // { l: 42.37, c: 0, h: 0, a: 1 }\ncolord(\"#646464\").alpha(0.5).toLchString(); // \"lch(42.37% 0 0 / 0.5)\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>minify</code> (Color string minification)</b> <i>0.5 KB</i></summary>\n\nA plugin adding color string minification utilities.\n\n```js\nimport { colord, extend } from \"colord\";\nimport minifyPlugin from \"colord/plugins/minify\";\n\nextend([minifyPlugin]);\n\ncolord(\"black\").minify(); // \"#000\"\ncolord(\"#112233\").minify(); // \"#123\"\ncolord(\"darkgray\").minify(); // \"#a9a9a9\"\ncolord(\"rgba(170,170,170,0.4)\").minify(); // \"hsla(0,0%,67%,.4)\"\ncolord(\"rgba(170,170,170,0.4)\").minify({ alphaHex: true }); // \"#aaa6\"\n```\n\n</details>\n\n<details>\n  <summary><b><code>mix</code> (Color mixing)</b> <i>1.01 KB</i></summary>\n\nA plugin adding color mixing utilities.\n\nIn contrast to other libraries that perform RGB values mixing, Colord mixes colors through [LAB color space](https://en.wikipedia.org/wiki/CIELAB_color_space) by default. This approach produces better results and doesn't have the drawbacks the legacy way has. If you need to match the alpha compositing of browsers and design tools instead, pass `\"rgb\"` as the last argument to interpolate RGB channels.\n\n→ [Online demo](https://3cg7o.csb.app/)\n\n```js\nimport { colord, extend } from \"colord\";\nimport mixPlugin from \"colord/plugins/mix\";\n\nextend([mixPlugin]);\n\ncolord(\"#ffffff\").mix(\"#000000\").toHex(); // \"#777777\"\ncolord(\"#800080\").mix(\"#dda0dd\").toHex(); // \"#af5cae\"\ncolord(\"#cd853f\").mix(\"#eee8aa\", 0.6).toHex(); // \"#e3c07e\"\ncolord(\"#008080\").mix(\"#808000\", 0.35).toHex(); // \"#50805d\"\ncolord(\"#ff0000\").mix(\"#ffffff\", 0.5, \"rgb\").toHex(); // \"#ff8080\"\n```\n\nAlso, the plugin provides special mixtures such as [tints, shades, and tones](https://en.wikipedia.org/wiki/Tints_and_shades):\n\n<div align=\"center\">\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Tint-tone-shade.svg/320px-Tint-tone-shade.svg.png\" alt=\"tints, shades, and tones mixtures\" />\n</div>\n\n```js\nconst color = colord(\"#ff0000\");\ncolor.tints(3).map((c) => c.toHex()); // [\"#ff0000\", \"#ff9f80\", \"#ffffff\"];\ncolor.shades(3).map((c) => c.toHex()); // [\"#ff0000\", \"#7a1b0b\", \"#000000\"];\ncolor.tones(3).map((c) => c.toHex()); // [\"#ff0000\", \"#c86147\", \"#808080\"];\n```\n\n</details>\n\n<details>\n  <summary><b><code>names</code> (CSS color keywords)</b> <i>1.45 KB</i></summary>\n\nProvides options to convert a color into a [CSS color keyword](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords) and vice versa.\n\n```js\nimport { colord, extend } from \"colord\";\nimport namesPlugin from \"colord/plugins/names\";\n\nextend([namesPlugin]);\n\ncolord(\"tomato\").toHex(); // \"#ff6347\"\ncolord(\"#00ffff\").toName(); // \"cyan\"\ncolord(\"rgba(0, 0, 0, 0)\").toName(); // \"transparent\"\ncolord(\"#fe0000\").toName(); // undefined (the color is not specified in CSS specs)\ncolord(\"#fe0000\").toName({ closest: true }); // \"red\" (closest color)\n```\n\n</details>\n\n<details>\n  <summary><b><code>xyz</code> (CIE XYZ color space)</b> <i>0.7 KB</i></summary>\n\nAdds support of [CIE XYZ](https://www.sttmedia.com/colormodel-xyz) color model. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code).\n\n```js\nimport { colord, extend } from \"colord\";\nimport xyzPlugin from \"colord/plugins/xyz\";\n\nextend([xyzPlugin]);\n\ncolord(\"#ffffff\").toXyz(); // { x: 95.047, y: 100, z: 108.883, a: 1 }\ncolord({ x: 0, y: 0, z: 0 }).toHex(); // \"#000000\"\n```\n\n</details>\n\n<div><img src=\"assets/divider.png\" width=\"838\" alt=\"---\" /></div>\n\n## Types\n\n**Colord** is written in strict TypeScript and ships with types in the library itself — no need for any other install. We provide everything you need in one tiny package.\n\nWhile not only typing its own functions and variables, **Colord** can also help you type yours. Depending on the color space you are using, you can also import and use the type that is associated with it.\n\n```ts\nimport { RgbColor, RgbaColor, HslColor, HslaColor, HsvColor, HsvaColor } from \"colord\";\n\nconst foo: HslColor = { h: 0, s: 0, l: 0 };\nconst bar: RgbColor = { r: 0, g: 0, v: 0 }; // ERROR\n```\n","publish_time":1787245798437,"_cnpm_publish_time":1787245798437,"dist-tags":{"latest":"2.11.0"}}