Skip to content

Nixie24/prettier-plugin-css-color-to-rgb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prettier-plugin-css-color-to-rgb

A Prettier plugin to convert CSS color values to RGB format( or CSS named value if possible ) for consistency and compatibility.

Installation

To install the plugin, use npm and add it to your project's devDependencies:

npm install --save-dev prettier-plugin-css-color-to-rgb

Usage

To use the plugin with Prettier, add it to your Prettier configuration file (.prettierrc) as follows:

{
    "plugins": ["prettier-plugin-css-color-to-rgb"]
}

Features

  • Automatic Conversion: Automatically recognizes and converts color values to rgb(red green blue[ / alpha]) format.
  • Named Colors: Converts color values that are equal to CSS named colors (e.g., red, blue, transparent) to their respective RGB values.

Example

Here's an example of how the plugin transforms CSS color values:

/* input */
:root {
    background-color: #ffe;
    color: rgb(0, 0, 0);
    border-color: rgb(240, 240, 240);
    box-shadow: 0 0 0 rgb(114 114 114 / 0%);
}

/* output */
:root {
    background-color: rgb(255 255 238);
    color: black;
    border-color: rgb(240 240 240);
    box-shadow: 0 0 0 transparent;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published