get-best-contrast-color
Advanced tools
Weekly downloads
Readme
get-best-contrast-color
calculates which color in an array of colors gives the highest contrast to another color.
Doesn't handle transparency as of yet.
$ npm install get-best-contrast-color
import bestContrast from 'get-best-contrast-color';
// If you're not using EMS but CommonJS:
// const bestContrast = require('get-best-contrast-color').default;
const background1 = 'palevioletred';
const background2 = 'saddlebrown';
const colors = [
'#222',
'blue',
'rgb(255, 255, ,255)',
];
bestContrast(background1, colors); // '#222'
bestContrast(background2, colors); // 'rgb(255, 255, 255)'
(background: string, colors: array) => string
I appreciate your issues and PRs on Github!
yarn build && yarn test
This project uses np.
yarn release
FAQs
Calculate the color in an array of colors that gives the highest contrast to another color.
The npm package get-best-contrast-color receives a total of 671 weekly downloads. As such, get-best-contrast-color popularity was classified as not popular.
We found that get-best-contrast-color demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.