Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yarastqt/postcss-theme-fallback

A postcss plugin to adding fallback values for css-variables
https://github.com/yarastqt/postcss-theme-fallback

css-vars css-vars-fallback postcss postcss-plugin

Last synced: 12 days ago
JSON representation

A postcss plugin to adding fallback values for css-variables

Awesome Lists containing this project

README

        

# postcss-theme-fallback [PostCSS][postcss]

[![NPM Version][npm-img]][npm-url] [![github (ci)][github-ci]][github-ci]

A postcss plugin to adding fallback values for css-variables.

## ✈️ Install

```sh
npm i -DE postcss-theme-fallback
```

## ☄️ Usage

```js
// postcss.config.js
module.exports = {
plugins: [
require('postcss-theme-fallback')({
// Use variables from object:
variables: {
'--var-a': '10px',
'--var-b': '20px',
},
// Or load variables from theme:
// themeSource: './src/theme/acme.css',
}),
],
}
```

### Options

| Name | Description | Default |
|---------------------------------------|--------------------------------------------------------|---------|
| `variables?` *Record* | Object with theme variables | |
| `themeSource?` *string* | A source path to theme, uses for extract css-variables | |
| `silent?` *boolean* | Disable warnings output | false |

## 🌈 Example

```css
/* input.css */
.component {
width: var(--var-a);
}

/* output.css */
.component {
width: var(--var-a, 10px);
}
```

## License

Project is [MIT licensed](https://github.com/yarastqt/postcss-theme-fallback/blob/master/LICENSE.md).

[npm-img]: https://img.shields.io/npm/v/postcss-theme-fallback.svg
[npm-url]: https://www.npmjs.com/package/postcss-theme-fallback
[github-ci]: https://github.com/yarastqt/postcss-theme-fallback/workflows/ci/badge.svg?branch=master
[PostCSS]: https://github.com/postcss/postcss