Get started
Install Colore, then change a button color or check its contrast in a few lines of JavaScript or TypeScript.
Install Colore
npm install colore-js
yarn add colore-js
You need Node.js 20 or later to run the examples locally.
Change a color and check its contrast
import { colore } from 'colore-js';
const button = colore('#2563eb');
console.log(button.lighten(8).hex()); // '#306ff8'
console.log(button.contrastRatio('#fff').toFixed(2)); // '5.17'
The lighter color is a new value. You can still use button for the default state. The second line measures the default blue against white, a ratio of about 5.17:1.
Import one operation
Use colore-js/fn if you need one operation and want the result as CSS.
import { mix } from 'colore-js/fn';
console.log(mix('#ff0000', '#0000ff', 0.5, 'oklab')); // '#8c53a2'
new Color(input) creates the same kind of object as colore(input). Either gives you methods for chaining several changes before you export.
Related
- API reference
- Check color contrast
- Coding agents and CLI for using Colore from your editor
- Theme generator to try a brand color before you write code
- How Colore compares if you're coming from another library, with pages for chroma.js and tinycolor2