Skip to content

Write real CSS in template strings and it gets injected in the head tag like ✨ optionally parse with any PostCSS plugin

License

Notifications You must be signed in to change notification settings

arturi/template-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template-css

Write CSS in template strings and it gets injected to DOM like ✨ Like so:

var css = require('template-css')

var colors = {
  red: '#c0392b',
  blue: '#2980b9'
}

var style = css`
  body {
    background-color: ${colors.red};
  }
  
  .title {
    font-size: 3em;
    font-weight: bold;
    color: ${colors.blue};
  }
`

Atom (and possibly other editors) will automatically syntax highlight your CSS inside template strings, when passed to a function called css.

You can also parse your CSS with any PostCSS plugin.

Runs any PostCSS plugin on the contents of your template string.

Example .babelrc

{
  "plugins": [
    ["babel-plugin-template-strings-postcss", {
      "plugins": [
        tagName: "css",
        ["autoprefixer", {"browsers": ["last 2 versions"]}],
        ["postcss-class-prefix", "MyPrefix-"],
        "postcss-nested"
      ]
    }]
  ]
}

See also

About

Write real CSS in template strings and it gets injected in the head tag like ✨ optionally parse with any PostCSS plugin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published