Vue Tailwind Components

2.5.1 · active · verified Wed Apr 22

Vue-Tailwind is a library of Vue 2 components designed to be highly customizable with Tailwind CSS classes. Unlike traditional UI libraries that provide opinionated styles, Vue-Tailwind allows developers to define their components' look and feel by providing custom default CSS classes, adding unlimited variants, and overriding default prop values. This approach aims to provide the best of both worlds: pre-built complex components (like modals, date pickers) while retaining full control over styling via a utility-first CSS framework. The current stable version is 2.5.1, and its release cadence appears moderate based on the provided release notes, focusing on fixes and feature additions for existing components. Its key differentiator is the deep integration with Tailwind CSS for granular styling control, making it suitable for projects with custom designs that still want component abstractions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the installation of `vue-tailwind` and how to register and globally configure specific components like TInput, TButton, and TCard with custom Tailwind CSS classes and default props, then renders them in a basic Vue application.

import Vue from 'vue';
import VueTailwind from 'vue-tailwind';
import {
  TInput,
  TButton,
  TCard
} from 'vue-tailwind/dist/components';

// Define custom settings for the components
const settings = {
  't-input': {
    component: TInput,
    props: {
      classes: 'border-2 border-gray-300 block w-full rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 text-gray-800',
      placeholder: 'Enter text here...'
    }
  },
  't-button': {
    component: TButton,
    props: {
      classes: 'inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500'
    }
  },
  't-card': {
    component: TCard,
    props: {
      classes: 'bg-white shadow-lg rounded-lg p-6'
    }
  }
};

Vue.use(VueTailwind, settings);

// Example Vue instance (in a .vue file or main.js)
new Vue({
  el: '#app',
  template: `
    <div id="app" class="p-8">
      <t-card class="mb-4">
        <h2 class="text-xl font-semibold mb-2">My Card Title</h2>
        <t-input class="mb-2" />
        <t-button>Submit</t-button>
      </t-card>
      <t-button>Another Button</t-button>
    </div>
  `
});

view raw JSON →