@csstools/postcss-stepped-value-functions
TypeScript icon, indicating that this package has built-in type declarations

4.0.8 • Public • Published

PostCSS Stepped Value Functions PostCSS Logo

npm install @csstools/postcss-stepped-value-functions --save-dev

PostCSS Stepped Value Functions lets you use round, rem and mod stepped value functions, following the CSS Values 4 specification.

.test-functions {
	padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%);
	transform: rotate(mod(-140deg, -90deg));
	top: round(15px, 4px);
	right: round(nearest, 15px, 4px);
	bottom: round(up, 15px, 7px);
	left: round(down, 15px, 4px);
	width: round(to-zero, 15px, 4px);
}

/* becomes */

.test-functions {
	padding: 8px 3px 1px calc(3px + 50%);
	transform: rotate(-50deg);
	top: 16px;
	right: 16px;
	bottom: 21px;
	left: 12px;
	width: 12px;
}

Usage

Add PostCSS Stepped Value Functions to your project:

npm install postcss @csstools/postcss-stepped-value-functions --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssSteppedValueFunctions = require('@csstools/postcss-stepped-value-functions');

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

⚠️ About custom properties

Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet.

Because of that, any usage that contains a var is skipped.

Options

preserve

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

postcssSteppedValueFunctions({ preserve: true })
.test-functions {
	padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%);
	transform: rotate(mod(-140deg, -90deg));
	top: round(15px, 4px);
	right: round(nearest, 15px, 4px);
	bottom: round(up, 15px, 7px);
	left: round(down, 15px, 4px);
	width: round(to-zero, 15px, 4px);
}

/* becomes */

.test-functions {
	padding: 8px 3px 1px calc(3px + 50%);
	padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%);
	transform: rotate(-50deg);
	transform: rotate(mod(-140deg, -90deg));
	top: 16px;
	top: round(15px, 4px);
	right: 16px;
	right: round(nearest, 15px, 4px);
	bottom: 21px;
	bottom: round(up, 15px, 7px);
	left: 12px;
	left: round(down, 15px, 4px);
	width: 12px;
	width: round(to-zero, 15px, 4px);
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.0.8258,413latest

Version History

VersionDownloads (Last 7 Days)Published
4.0.8258,413
4.0.7235,622
4.0.6109,249
4.0.598,444
4.0.48,931
4.0.36,192
4.0.28,133
4.0.164,455
4.0.02,898
3.0.10262,590
3.0.96,313
3.0.854,710
3.0.70
3.0.629,490
3.0.517,223
3.0.428,466
3.0.33,558
3.0.254,400
3.0.118,437
3.0.02,271
2.1.1145,861
2.1.024,227
2.0.13,612
2.0.0768
1.0.12,563,877
1.0.074,883

Package Sidebar

Install

npm i @csstools/postcss-stepped-value-functions

Weekly Downloads

4,083,023

Version

4.0.8

License

MIT-0

Unpacked Size

6.97 kB

Total Files

7

Last publish

Collaborators

  • jonathantneal
  • alaguna
  • romainmenke