Getting Started

Installation

Add the build plugin and the editor types to a Nuxt or Vite project.

A project needs two pieces: the build plugin, which turns each block into classes, and the editor plugin, which tells the editor and vue-tsc what classes holds. In Nuxt, the module sets up both.

Requirements

  • Vue 3.3 or newer
  • Nuxt 3.10 or newer, or Vite 5 or newer
  • Tailwind CSS v3 or v4
  • Vue - Official VS Code extension and vue-tsc 3.2 or newer, for editor types
  • ESLint 9 or 10 with flat config, for linting

Install

Add the package

pnpm add -D vue-tailwind-block

Register the module

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

The module automatically configures the Vite build plugin and injects the editor types into the tsconfig Nuxt generates.

Run npx nuxi prepare (or start the dev server), then reload your editor window (Cmd/Ctrl + Shift + P → Developer: Reload Window) so the language server loads the plugin.

Tailwind CSS IntelliSense

The Tailwind CSS IntelliSense extension only inspects standard class attributes by default. Add this setting to .vscode/settings.json so it scans <tailwind> blocks for autocomplete, color swatches, and hovers:

.vscode/settings.json
{
  "tailwindCSS.experimental.classRegex": [
    ["<tailwind[^>]*>([\\s\\S]*?)</tailwind>", "(?:^|\\n)[ \\t]*(?:-[ \\t]+|[^\\s:#\"'][^:\\n]*:[ \\t]+)[\"']?([^\\n#\"']+)"]
  ]
}

Renaming the variable (binding)

By default, the block compiles to a variable called classes. If a prop or another identifier already uses that name, customize it with binding:

export default defineNuxtConfig({
  modules: ['vue-tailwind-block/nuxt'],
  tailwindBlock: {
    binding: 'styles',
  },
})
In Vite projects, ensure the same binding is configured in both vite.config.ts and your tsconfig. In Nuxt, setting it in nuxt.config.ts configures both automatically.

Verify

Add a block to any component and use classes in its template:

Card.vue
<template>
  <div :class="classes.root">
    <slot />
  </div>
</template>

<tailwind lang="yaml">
root: rounded-lg border p-6 shadow-sm
</tailwind>

If the card renders with styling, the build plugin is active. If your editor underlines classes as undefined:

  1. Verify the component uses <script setup lang="ts"> (in plain JavaScript, classes is typed as any).
  2. Verify that your tsconfig includes the .vue file and contains the vueCompilerOptions.plugins entry.
  3. In Nuxt, run npx nuxi prepare.
  4. Restart the language server (Vue: Restart Vue Language Server).
Copyright © 2026