postcss-double-position-gradients

Use double-position gradients in CSS

MIT-0 31 个版本
安装
npm install postcss-double-position-gradients
yarn add postcss-double-position-gradients
pnpm add postcss-double-position-gradients
bun add postcss-double-position-gradients
README

PostCSS Double Position Gradients PostCSS

NPM Version Discord

Baseline Status CSS Standard Status

PostCSS Double Position Gradients lets you use double-position gradients in CSS, following the CSS Image Values and Replaced Content specification.

.linear-gradient {
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

/* becomes */

.linear-gradient {
  background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

Usage

Add PostCSS Double Position Gradients to your project:

npm install postcss-double-position-gradients --save-dev

Use PostCSS Double Position Gradients to process your CSS:

const postcssDoublePositionGradients = require('postcss-double-position-gradients');

postcssDoublePositionGradients.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssDoublePositionGradients = require('postcss-double-position-gradients');

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

PostCSS Double Position Gradients runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Gulp Grunt

Options

preserve

The preserve option determines whether the original double-position gradients should be preserved. By default, double-position gradients are preserved.

postcssDoublePositionGradients({ preserve: false })
.linear-gradient {
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

/* becomes */

.linear-gradient {
  background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
}

enableProgressiveCustomProperties

The enableProgressiveCustomProperties option determines whether the original notation is wrapped with @supports when used in Custom Properties. By default, it is enabled.

[!NOTE] We only recommend disabling this when you set preserve to false or if you bring your own fix for Custom Properties.
See what the plugin does in its README.

postcssDoublePositionGradients({ enableProgressiveCustomProperties: false })
:root {
	--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

/* becomes */

:root {
	--a-gradient: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%); /* will never be used, not even in older browser */
	--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}
版本列表
7.0.1 2026-05-13
7.0.0 2026-01-14
6.0.4 2025-09-21
6.0.3 2025-08-22
6.0.2 2025-05-27
6.0.1 2025-04-19
6.0.0 2024-08-03
5.0.7 2024-07-07
5.0.6 2024-03-31
5.0.5 2024-03-13
5.0.4 2024-02-19
5.0.3 2023-12-15
5.0.2 2023-10-09
5.0.1 2023-09-18
5.0.0 2023-07-03
4.0.4 2023-06-01
4.0.3 2023-05-19
4.0.2 2023-02-08
4.0.1 2023-01-28
4.0.0 2023-01-24
3.1.2 2022-07-08
3.1.1 2022-03-07
3.1.0 2022-02-15
3.0.5 2022-02-05
3.0.4 2022-01-02
3.0.3 2021-12-14
3.0.2 2021-12-13
3.0.1 2021-11-18
3.0.0 2021-09-17
2.0.0 2020-04-26
1.0.0 2018-10-28