variantwind
Tailwind Variant Directive for Vue
1,934
| Install | |
|---|---|
npm install variantwind |
|
| Latest Version: | 0.13.0 |
| Vue: | 2 · 3 |
| License: | MIT |
| Last Updated: | Dec 8, 2020 |
| Links: | npm |
Maintainer: sibbngheid
variantwind
Most elegant way to work with TailwindCSS variants in Vue
Use as directive or binding, supports both Vue 2 & 3, also supports PurgeCSS🔥🔥
Installation
yarn add variantwind # or `npm i variantwind`
CDN
<script src"https://unpkg.com/variantwind"></script>
Usage
import { createApp } from "vue";
import App from "./App.vue";
import Variantwind from "variantwind";
const app = createApp(App);
/**
* Directives: v-variantwind
* Methods: $variantwind
*/
app.use(Variantwind, "variantwind");
/* ===== OR =====*/
/**
* Directives: v-variantwind v-dark
* Methods: $variantwind $dark
*
* Note: This plugin doesn't provide dark mode functionality. This is just a use case example.
*/
app.use(Variantwind, ["variantwind", "dark"]);
app.mount("#app");
<template>
<div
class="w-full bg-red-500 md:{w-1/3 bg-blue-500} lg:{w-1/4 bg-yellow-500 hover:bg-yellow-900}"
v-variantwind
>
Middleware
</div>
<div
v-variantwind="'w-full bg-red-500 md:{w-1/3 bg-blue-500} lg:{w-1/4 bg-yellow-500 hover:bg-yellow-900}'"
>
Directive binding
</div>
<div
v-variantwind="'w-full bg-red-500 md:{w-1/3 bg-blue-500} lg:{w-1/4 bg-yellow-500 hover:bg-yellow-900}'"
v-dark="'dark:{bg-black-900 text-white}'"
>
Multiple directives
</div>
<div
:class="variantwind('lg:{w-1/4 bg-yellow-500 hover:bg-yellow-900}')"
:class="$variantwind('lg:{w-1/4 bg-yellow-500 hover:bg-yellow-900}')"
>
Local and Global Class binding
</div>
<div
class="w-full bg-red-500 md:{w-1/3 bg-blue-500}"
:class="$variantwind('lg:{w-1/4 bg-green-500 hover:bg-green-900}')"
v-variantwind="'xl:{w-1/4 bg-yellow-500 hover:bg-yellow-900}'"
v-dark="'dark:{bg-black-900 text-white}'"
>
You can use all of them together.
</div>
</template>
<script>
import { variantwind } from "variantwind";
export default {
// Pass function to template for local class binding usage
methods: { variantwind },
};
</script>
TailwindCSS Purge
// tailwind.config.js
const { extractor } = require("variantwind");
module.exports = {
purge: {
content: ["./index.html", "./src/**/*.vue", "./src/**/*.js"],
options: {
extractors: [
{
extractor,
extensions: ["vue"],
},
],
},
},
};
License
MIT License © 2020 sibbng
Related Packages
tailwindcss-rtl
Right-to-left (RTL) and logical-direction utilities for Tailwind CSS v3 and v4
2,280,783
355
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.13.0 | ^3 || | MIT | |
| 0.12.1 | ^3.0.0-rc.5 || | MIT | |
| 0.12.0 | ^3.0.0-rc.5 || | MIT | |
| 0.11.2 | ^3.0.0-rc.5 || | MIT | |
| 0.11.1 | ^3.0.0-rc.5 || | MIT | |
| 0.11.0 | ^3.0.0-rc.5 || | MIT | |
| 0.10.2 | ^3.0.0-rc.5 || | MIT | |
| 0.10.1 | ^3.0.0-rc.5 || | MIT | |
| 0.10.0 | ^3.0.0-rc.5 || | MIT | |
| 0.9.2 | ^3.0.0-rc.5 || | MIT | |
| 0.9.1 | ^3.0.0-rc.5 || | MIT | |
| 0.9.0 | ^3.0.0-rc.5 || | MIT | |
| 0.8.3 | ^3.0.0-rc.5 || | MIT | |
| 0.8.2 | ^3.0.0-rc.5 || | MIT | |
| 0.8.1 | ^3.0.0-rc.5 || | MIT | |
| 0.8.0 | ^3.0.0-rc.5 || | MIT | |
| 0.7.1 | ^3.0.0-rc.5 | MIT | |
| 0.7.0 | ^3.0.0-rc.5 | MIT | |
| 0.6.6 | ^3.0.0-rc.5 | MIT | |
| 0.6.5 | ^3.0.0-rc.5 | MIT | |
| 0.6.4 | ^3.0.0-rc.5 | MIT | |
| 0.6.3 | ^3.0.0-rc.5 | MIT | |
| 0.6.2 | ^3.0.0-rc.5 | MIT | |
| 0.6.1 | ^3.0.0-rc.5 | MIT | |
| 0.6.0 | ^3.0.0-rc.5 | MIT | |
| 0.5.1 | MIT | ||
| 0.5.0 | MIT | ||
| 0.4.4 | MIT | ||
| 0.4.3 | MIT | ||
| 0.4.2 | MIT |
Showing the latest 30 of 41. See every release on npm