Socket
Socket
Sign inDemoInstall

@csstools/postcss-relative-color-syntax

Package Overview
Dependencies
12
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @csstools/postcss-relative-color-syntax

Use the relative color syntax in CSS


Version published
Maintainers
3
Created

Package description

What is @csstools/postcss-relative-color-syntax?

@csstools/postcss-relative-color-syntax is a PostCSS plugin that allows you to use relative color syntax in your CSS. This can simplify color manipulations and make your stylesheets more maintainable by enabling relative color adjustments directly in your CSS.

What are @csstools/postcss-relative-color-syntax's main functionalities?

Relative Color Syntax

This feature allows you to use relative color syntax to mix colors directly in your CSS. The example shows how to mix white and black to get a gray background color.

/* Input CSS */
body {
  background-color: color-mix(in srgb, white 50%, black);
}

/* Output CSS */
body {
  background-color: #808080;
}

Color Adjustments

This feature allows you to adjust colors based on contrast. The example shows how to set a button's background color to blue while ensuring it contrasts well with both white and black.

/* Input CSS */
button {
  background-color: color-contrast(white vs black, blue);
}

/* Output CSS */
button {
  background-color: #0000ff;
}

Other packages similar to @csstools/postcss-relative-color-syntax

Readme

Source

PostCSS Relative Color Syntax PostCSS Logo

npm version Build Status Discord

Baseline Status CSS Standard Status

npm install @csstools/postcss-relative-color-syntax --save-dev

PostCSS Relative Color Syntax lets you use the relative color syntax in CSS color functions following CSS Color Module 5.

.example {
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}

/* becomes */

.example {
	background: rgb(12, 100, 100);
}

[!NOTE] We can not dynamically resolve var() arguments in relative color syntax, only static values will work.

Usage

Add PostCSS Relative Color Syntax to your project:

npm install postcss @csstools/postcss-relative-color-syntax --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssRelativeColorSyntax = require('@csstools/postcss-relative-color-syntax');

postcss([
	postcssRelativeColorSyntax(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Relative Color Syntax runs in all Node environments, with special instructions for:

Options

preserve

The preserve option determines whether the original notation is preserved. By default, it is not preserved.

postcssRelativeColorSyntax({ preserve: true })
.example {
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}

/* becomes */

.example {
	background: rgb(12, 100, 100);
	background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b);
}

Keywords

FAQs

Last updated on 04 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc