vue-custom-properties
Version:
Make easier to use CSS custom properties in Vue components
47 lines (34 loc) • 686 B
Markdown
Make easier to use CSS custom properties in Vue components
```bash
$ npm install --save vue-custom-properties
$ yarn add vue-custom-properties
```
1. Install it into Vue.js.
```js
import Vue from 'vue'
import VueCustomProperties from 'vue-custom-properties'
Vue.use(VueCustomProperties)
```
2. Define `customProperties` option in your components.
```js
export default {
data() {
return {
color: 'red',
size: 12
}
},
customProperties: {
'--base-color': 'color', // --base-color: red;
'--base-size'() {
return this.size + 'px' // --base-size: 12px;
}
}
}
```
MIT