All Projects → vitaliy-bobrov → Postcss Register Custom Props

vitaliy-bobrov / Postcss Register Custom Props

Licence: mit
PostCSS plugin that transforms custom property registration in CSS to JS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postcss Register Custom Props

Postcss Easing Gradients
PostCSS plugin to create smooth linear-gradients that approximate easing functions.
Stars: ✭ 689 (+3345%)
Mutual labels:  postcss, postcss-plugin
postcss-aspect-ratio
A PostCSS plugin to fix an element's dimensions to an aspect ratio.
Stars: ✭ 38 (+90%)
Mutual labels:  postcss, postcss-plugin
postcss-clean
PostCss plugin to minify your CSS with clean-css
Stars: ✭ 41 (+105%)
Mutual labels:  postcss, postcss-plugin
Postcss Position
PostCSS plugin that adds shorthand declarations for position attributes
Stars: ✭ 26 (+30%)
Mutual labels:  postcss, postcss-plugin
Postcss Interpolate
PostCSS plugin for values interpolation between breakpoints.
Stars: ✭ 9 (-55%)
Mutual labels:  postcss, postcss-plugin
postcss-font-pack
PostCSS plugin to simplify font declarations by validating only configured font packs are used and adding fallbacks.
Stars: ✭ 18 (-10%)
Mutual labels:  postcss, postcss-plugin
postcss-typed-css-classes
PostCSS plugin that generates typed entities from CSS classes for chosen programming language.
Stars: ✭ 12 (-40%)
Mutual labels:  postcss, postcss-plugin
postcss-prefixwrap
A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Stars: ✭ 54 (+170%)
Mutual labels:  postcss, postcss-plugin
postcss-momentum-scrolling
PostCSS plugin add 'momentum' style scrolling behavior (-webkit-overflow-scrolling: touch) for elements with overflow (scroll, auto) on iOS
Stars: ✭ 69 (+245%)
Mutual labels:  postcss, postcss-plugin
postcss-relaxed-unit
🍮Postcss-relaxed-unit is a postcss plugin for unit tranformation and make write css easier with custom unit.
Stars: ✭ 44 (+120%)
Mutual labels:  postcss, postcss-plugin
Purgecss
Remove unused CSS
Stars: ✭ 6,566 (+32730%)
Mutual labels:  postcss-plugin, postcss
Postcss Sprites
Generate sprites from stylesheets.
Stars: ✭ 402 (+1910%)
Mutual labels:  postcss, postcss-plugin
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (+15%)
Mutual labels:  postcss, postcss-plugin
postcss-lazyimagecss
A PostCSS plugin that generates images's CSS width & height properties automatically.
Stars: ✭ 38 (+90%)
Mutual labels:  postcss, postcss-plugin
postcss-windicss
PostCSS integrations for Windi CSS
Stars: ✭ 33 (+65%)
Mutual labels:  postcss, postcss-plugin
postcss-define-function
PostCSS plugin for Sass-like function directive
Stars: ✭ 25 (+25%)
Mutual labels:  postcss, postcss-plugin
postcss
No description or website provided.
Stars: ✭ 59 (+195%)
Mutual labels:  postcss, postcss-plugin
postcss-purgecss
PostCSS plugin for purgecss
Stars: ✭ 92 (+360%)
Mutual labels:  postcss, postcss-plugin
postcss-sort-media-queries
PostCSS plugin for combine and sort CSS media queries with mobile first or desktop first methods.
Stars: ✭ 118 (+490%)
Mutual labels:  postcss, postcss-plugin
Postcss Responsive Type
Automagical responsive typography, built on PostCSS
Stars: ✭ 363 (+1715%)
Mutual labels:  postcss, postcss-plugin

postcss-register-custom-props

Build Status npm version npm

PostCSS plugin that transforms custom property registration in CSS to JS.

According to the current "Custom Properties and Values API Level 1" specification you can register custom property with JavaScript, like:

CSS.registerProperty({
  name: "--highlight-color",
  syntax: "<color>",
  initialValue: "red",
  inherits: false
});

There is a proposal to the "Custom Properties and Values API Level 2" specification to make it possible to do the same in CSS:

@property --highlight-color {
  syntax: '<color>';
  initial-value: red;
  inherits: false;
}

This PostCSS plugin allows you to declare custom property in CSS and generate JavaScript file that contains registrations.

Input:

@property --theme {
  syntax: '<color>+';
  initial-value: #fff;
  inherits: true;
}

Output:

if ("registerProperty" in CSS) {
  CSS.registerProperty({
    name: "--theme",
    syntax: "<color>+",
    initialValue: "#fff",
    inherits: true
  });
}

Installation

  • npm: npm install --save-dev postcss-register-custom-props

  • yarn: yarn add -D postcss-register-custom-propsk

Usage

postcss([ require('postcss-register-custom-props')( /* options */ ) ])

See [PostCSS] docs for examples of your environment.

Options

output

Specifies custom properties JavaScript file path and name. Defaults to ./custom-properties.js.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].