Skip to content

AnandChowdhary/inverted-colors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ‘ Inverted colors

Travis CI Coverage Status GitHub Vulnerabilities NPM type definitions NPM Minzipped size

NPM

Inverted colors is a package that tells you whether a user prefers inverted colors. It's based on the CSS @media (inverted-colors), which is part of Media Queries Level 5. It's around 700 bytes minified, 300 bytes gzipped.

⭐ Usage

Add the dependency from NPM:

npm install inverted-colors

Import the package:

import invertedColors from "inverted-colors";

Then call the function:

const colorPreference = invertedColors();
// Returns "none" or "inverted"

πŸ’‘ Browser support

This package only works in browsers that natively support @media (inverted-colors), so it just returns "none" in unsupported browsers. Current browser support

By passing false as the argument, you can get "unsupported" as the value for unsupported browsers:

const colorPreference = invertedColors(false);
// Returns "inverted", "none", or "unsupported"

πŸ› οΈ Development

Install dependencies:

yarn

Compile Typescript to ES6 before publishing to NPM:

yarn build

πŸ“€ Media Queries Level 5

  • πŸ™… prefers-reduced-motion Β· GitHub Β· NPM
  • 🎨 prefers-color-scheme Β· GitHub Β· NPM
  • πŸ•ΆοΈ prefers-contrast Β· GitHub Β· NPM
  • 🎞️ prefers-reduced-transparency Β· GitHub Β· NPM
  • πŸŒ‘ inverted-colors Β· GitHub Β· NPM
  • πŸ§– environment-blending Β· GitHub Β· NPM
  • πŸ’‘ light-level Β· GitHub Β· NPM

πŸ“ License

MIT