JSFiddle - React, Tailwind, and code Playground

by Serghei Cebotari

HTML

<script src="https://unpkg.com/vue/dist/vue.js"></script>

<div id="app">
  <div class="demo" :style="myStyle"></div>
  <div class="demo"></div>
  <div class="demo" :style="[myStyle, {height: width + 'px'}]"></div>
  <hr>
  <input type="text" v-model="color">
  <input type="text" v-model="width">
</div>

CSS

.demo {
  width: 100px;
  height: 100px;
  margin: 10px;
  display: inline-block;
  background-color: gray;
}

.red {
  background-color: red;
}
.green {
  background-color: green;
}
.blue {
  background-color: blue;
}

JavaScript

new Vue({
	el: '#app',
  data: {
    color: 'grey',
    width: 100
  },
  computed: {
  	myStyle: function() {
    	return {
      	backgroundColor: this.color,
        width: this.width + 'px'
      }
    }
  }
});