Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-variables

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-variables

Converts variables into CSS

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

PostCSS Variables

Converts variables into CSS.

/* before (nesting requires postcss-nested) */

$dir: assets/icons;
$color: blue;

.block {
	background: url('$(dir)/foo.png');
	&__elem {
		$color: green;
		color: $color;
	}
	&__elem2 {
		color: $color;
	}
}

/* after */

.block {
	background: url('assets/icons/foo.png');
	&__elem {
		color: green;
	}
	&__elem2 {
		color: blue;
	}
}

Usage

Add PostCSS Variables to your build tool:

npm install postcss-variables --save-dev
Node
require('postcss-variables')({ /* options */ }).process(YOUR_CSS);
PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load PostCSS Variables as a PostCSS plugin:

postcss([
	require('postcss-variables')({ /* options */ })
]);

Options

globals

Type: Object
Default: {}

Specifies your own global variables.

require('postcss-variables')({
	globals: {
		siteWidth: '960px',
		colors: {
			primary: '#fff',
			secondary: '#000'
		}
	}
});
/* before */

.hero {
	color: $colors.primary;
	max-width: $siteWidth;
}

/* after */

.hero {
	color: #fff;
	max-width: 960px;
}

Note: Please refer to Advanced Variables for more advanced features. This library is essentially a simplification and alteration of that plugin. Thank you to the author for making it available.

FAQs

Package last updated on 29 Nov 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc