Building A Tailwind CSS Component Library for Vue.js

Building A Tailwind CSS Component Library for Vue.js

Tailwindcss-Vue - Tailwindcss-Vue is a library of UI components for Vue.js built using the Tailwind CSS utility-first CSS framework.



npm install @advanced-data-machines/tailwindcss-vue


yarn add @advanced-data-machines/tailwindcss-vue


import Vue from 'vue';
// styles for transitions and other base options
import '@advanced-data-machines/tailwindcss-vue/dist/tailwindcss-vue.css';
import TailwindcssVue from '@advanced-data-machines/tailwindcss-vue';


Base Theme Expectations

Use of this project assumes you are using PostCSS and Tailwind CSS in your Vue project.


// replace './tailwind.config.js' to your own config path
module.exports = {
    plugins: [


This file is likely to change to base color scheme without the need for custom color names

const { colors } = require('tailwindcss/defaultTheme');
// variant defaults
module.exports = {
    theme: {
        extend: {
            spacing: {
                '9': '2.25rem',
                '11': '2.75rem',
                '14': '3.5rem',
                '18': '4.5rem'
            fontSize: {
                'xxs': '0.625rem'
            stroke: {
        container: {
            center: true
    variants: {
        borderColor: ['responsive', 'hover', 'focus', 'first', 'last'],
        borderRadius: ['responsive', 'first', 'last'],
        borderWidth: ['responsive', 'first', 'last'],
        margin: ['responsive', 'before', 'first', 'last'],
        textColor: ['responsive', 'hover', 'focus', 'before']
    plugins: [
        function({ addVariant, e }) {
            addVariant('before', ({ modifySelectors, separator }) => {
                modifySelectors(({ className }) => {
                    return `.${e(`before${separator}${className}`)}:before`;

Developing/Running Locally

Clone the repo to your computer then change to the project directory. Once in the root of the project, use the install command with your dependency manager of choice (yarn or npm).

cd tailwindcss-vue
npm install


cd tailwindcss-vue
yarn install

The project is set up with a Vue SPA playground to test components. In the root of the project directory you can run the development server with the serve command.

npm run serve


yarn serve

You can also build the project and serve it to another local project using npm link or the equivalent yarn link. While still in the root of the project directory, run the build:bundle command.

npm run build:bundle


yarn build:bundle

This will add the build to the 'dist' folder as a consumable library. Once completed, run the npm link command.

npm link

Next, in the project you wish to link, run the npm link tailwindcss-vue in the same directory as the package.json file. This will add the project to the global scope to be referenced as a traditional installed npm package (import TailwindcssVue from '@advanced-data-machines/tailwindcss-vue').

npm link @advanced-data-machines/tailwindcss-vue

Local Docs

This project is bundled with VuePress to generate its documentation. You can run it locally by running the docs:dev run command. The docs are currently a work-in-progress.

npm run docs:dev


yarn docs:dev



Originally published at

vue-js javascript

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

What are the differences between the various JavaScript frameworks? E.g. Vue.js, Angular.js, React.js

What are the differences? Do they each have specific use contexts?

Ember.js vs Vue.js - Which is JavaScript Framework Works Better for You

In this article we will discuss full details and comparison of both Ember.js and Vue.js

Top Vue.js Developers in USA

Vue.js is an extensively popular JavaScript framework with which you can create powerful as well as interactive interfaces. Vue.js is the best framework when it comes to building a single web and mobile apps.

Convert String To Number/Array In JavaScript with React Hooks/Vue.JS Examples

In this tutorial, we'll learn by example how to convert a string to the corresponding integer or float number or array of numbers using the built-in JavaScript methods with simple React and Vue.js examples.