More Premium Hugo Themes Premium Vue Themes

Vue Tailwind

Vue UI components with configurable classes ready for TailwindCSS

Vue Tailwind

Vue UI components with configurable classes ready for TailwindCSS

Author Avatar Theme by alfonsobries
Github Stars Github Stars: 2169
Last Commit Last Commit: Apr 15, 2022 -
First Commit Created: Apr 22, 2023 -
default image

Overview:

VueTailwind is a set of Vue components that can be customized to adapt to the unique design of any application. Unlike other UI libraries, which rely on CSS frameworks with limited styles, VueTailwind allows users to define custom CSS classes and configure component settings, providing a balance between pre-defined styles and customization. With VueTailwind, users can define the look and feel of their components, add unlimited variants for different use cases, override default props, and create different versions of components with different default settings.

Features:

  • Customizable Vue components
  • Ability to define custom default CSS classes
  • Configurable component settings
  • Support for unlimited variants
  • Override default prop values
  • Create different versions of components with different default settings

Installation:

  1. Install the dependencies.

    npm install
    
  2. Install TailwindCSS (Optional).
    This library uses TailwindCSS classes by default, but it should work with any CSS framework. To install TailwindCSS, follow the official documentation here.

  3. Add the @tailwindcss/forms plugin.
    The default theme of this library depends on the @tailwindcss/forms plugin. To use it, follow the steps on the plugin source page here.

  4. Add variants for disabled pseudo-class.
    This step is strongly recommended as it adds the ability to use some classes like disabled:opacity-50 and disabled:cursor-not-allowed for disabled inputs. Refer to the TailwindCSS documentation here for more information. As a reference, your tailwind.config.js may look like this:

    module.exports = {
      variants: {
        extend: {
          opacity: ['disabled'],
          cursor: ['disabled'],
        },
      },
    }
    
  5. Configure Vue to use vue-tailwind.

    5.1 Import and install the components.

    import Vue from 'vue'
    import VueTailwind from 'vue-tailwind'
    
    import { TButton, TInput } from 'vue-tailwind/dist/components'
    
    const settings = {
      't-button': {
        component: TButton,
        props: {
          classes: 'text-white bg-blue-500 border-0 py-2 px-4 focus:outline-none hover:bg-blue-600 rounded',
          variants: {
            secondary: 'text-blue-500 bg-white border-blue-500 hover:text-white hover:bg-blue-600 hover:border-blue-600',
          },
          fixedClasses: 'focus:outline-none',
        },
      },
      't-input': {
        classes: 'appearance-none bg-transparent border-none w-full text-gray-700 mr-3 py-1 px-2 leading-tight focus:outline-none',
        variants: {
          error: 'border-red-500 bg-red-100',
          disabled: 'opacity-50 cursor-not-allowed',
        },
        fixedClasses: 'focus:border-blue-500',
      },
    }
    
    Vue.use(VueTailwind, settings)
    

    5.2 Alternatively, you can use the v1.0 syntax.

    import Vue from 'vue'
    import VueTailwind from 'vue-tailwind'
    
    import { TButton, TInput } from 'vue-tailwind/dist/components'
    
    const settings = {
      't-button': {
        component: TButton,
        props: {
          classes: 'text-white bg-blue-500 border-0 py-2 px-4 focus:outline-none hover:bg-blue-600 rounded',
          variants: {
            secondary: 'text-blue-500 bg-white border-blue-500 hover:text-white hover:bg-blue-600 hover:border-blue-600',
          },
          fixedClasses: 'focus:outline-none',
        },
      },
      't-input': {
        component: TInput,
        props: {
          classes: 'appearance-none bg-transparent border-none w-full text-gray-700 mr-3 py-1 px-2 leading-tight focus:outline-none',
          variants: {
            error: 'border-red-500 bg-red-100',
            disabled: 'opacity-50 cursor-not-allowed',
          },
          fixedClasses: 'focus:border-blue-500',
        },
      },
    }
    
    Vue.use(VueTailwind, settings)
    

    5.3 Or install only the components you need.

    import Vue from 'vue'
    import VueTailwind from 'vue-tailwind'
    
    import { TButton, TInput } from 'vue-tailwind/dist/components'
    
    const settings = {
      't-button': {
        component: TButton,
        props: {
          class: 'text-white bg-blue-500 border-0 py-2 px-4 focus:outline-none hover:bg-blue-600 rounded',
          fixedClasses: 'focus:outline-none',
        },
      },
      't-input': TInput,
    }
    
    Vue.use(VueTailwind, settings)
    

Note: Using the syntax from point 5.3 is the best way to prevent a large bundle size, but it is only recommended if you are importing a few components. If the number of components you install increases, it is recommended to use the syntax from points 5.1 or 5.2 to help the library reuse some code and keep the bundle size minimal.

Summary:

VueTailwind is a customizable Vue component library that allows users to define their own default CSS classes and configure component settings. It provides the flexibility to create unique designs while still benefiting from pre-defined components. The installation process involves installing dependencies, optionally installing TailwindCSS and the @tailwindcss/forms plugin, and configuring Vue to use vue-tailwind. With VueTailwind, users can easily customize the look and feel of their components, add unlimited variants for different use cases, override default props, and create different versions of components with different default settings.