vue-tailwind-block

Keep long Tailwind utility classes out of your Vue templates with a typed YAML block for Vite and Nuxt.
569
Install
npm install vue-tailwind-block
Latest Version:1.0.1
Vue:3
License:ISC
Last Updated:Oct 18, 2026
Links: GitHub  ·  npm
Maintainer: astraldev

vue-tailwind-block

Write the Tailwind classes of a Vue component as YAML in a <tailwind lang="yaml"> block, grouped by variant and commented where needed. At build time the block becomes a classes object that the template and the script read like any other variable.

<template>
  <button :class="[classes.root, classes.variants[variant]]">
    <slot />
  </button>
</template>

<script setup lang="ts">
defineProps<{ variant: 'primary' | 'outline' }>()
</script>

<tailwind lang="yaml">
root:
  - inline-flex items-center rounded-md px-4 py-2
  - disabled:pointer-events-none disabled:opacity-50 # no clicks while disabled
variants:
  primary: bg-black text-white hover:bg-black/80
  outline: border hover:bg-gray-100
</tailwind>

Install

pnpm add -D vue-tailwind-block

In Nuxt 3.10 or newer, add the module. It also sets up the editor types:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['vue-tailwind-block/nuxt'],
})

In Vite, add the plugin next to vue(), and the editor plugin to tsconfig.json:

// vite.config.ts
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import tailwindBlock from 'vue-tailwind-block/vite'

export default defineConfig({
  plugins: [tailwindBlock(), vue()],
})
{
  "vueCompilerOptions": {
    "plugins": [{ "name": "vue-tailwind-block/volar" }]
  }
}

Works with Tailwind CSS v3 and v4. With v3, include your .vue files in content so Tailwind sees the classes in the block.

Documentation

Visit the documentation at vue-tailwind-block.netlify.app. You can also run pnpm docs:dev to read them locally.

Related Packages

unplugin-vue-prop

Add import define props type support for Vue3 script-setup and lang is typescrip...

1,105 2
mockline

Mockline is a premium UI Kit for Nuxt and VueJS based on TailwindCSS. It provide...

1,349 13
@mockline/utils

Mockline Utils is the minimal utility library for Mockline. To kickstart your pr...

789 13
nuxt-windicss

Windi CSS for Nuxt.js

227,810 328

Version History

Version Released Vue License
1.0.1 ^3.3.0 || ^3.6.0-0 ISC
1.0.0 ^3.3.0 || ^3.6.0-0 ISC
Pre-releases (1)
Version Released License
0.0.0-stage