Update v4.2 - New components, 10+ framework guides, and quality improvements. Visit Changelog

Install Preline UI with Vue.js using Tailwind CSS

Install Preline UI with Tailwind CSS in Vue.js projects, including JavaScript plugin setup, Vite configuration, router rescans, and optional dependencies.

Installation

Please note that the plugin has been tested with the 3.5.13 version of the framework. The framework was installed using the standard npm create vue@latest command.
If you are using your own project structure or a different version, pay attention to the file paths and features of your version!

Vue.js quick setup

If Tailwind CSS is not set up yet, start with the official Vue + Vite Tailwind CSS guide first.

Preline UI + Vue

Some components rely on third-party libraries. The setup below assumes full use of Preline UI, including those optional dependencies. If you do not need those components, you can trim the related packages and configuration.

  1. Install Preline UI

    Install preline with your preferred package manager.

    Terminal
                              
                                npm install preline
                              
                            

    Preline UI uses the Tailwind CSS Forms plugin across form components. If you have not added it yet, install it with npm install -D @tailwindcss/forms.

  2. Include Preline CSS

    Import Preline into project_root_directory/src/assets/main.css.

    main.css
                              
                                @import "tailwindcss";
                                
                                @import "preline/variants.css";
                                @source "../../node_modules/preline/dist/*.js";
    
                                /* Optional Preline UI Datepicker Plugin */
                                /* @import "preline/src/plugins/datepicker/styles.css"; */
    
                                /* Third-party plugins */
                                /* @plugin "@tailwindcss/forms"; */
    
                                /* Preline Themes */
                                @import "./themes/theme.css";
                              
                            

    See the Theme docs to learn more about Preline Themes.

  3. Add type definitions for Preline

    Create a global.d.ts file for the shared window typings, for example project_root_directory/src/global.d.ts.

    global.d.ts
                              
                                import type { IStaticMethods } from "preline/dist";
    
                                declare global {
                                  interface Window {
                                    // Optional third-party libraries
                                    _;
                                    $: typeof import("jquery");
                                    jQuery: typeof import("jquery");
                                    DataTable;
                                    Dropzone;
                                    VanillaCalendarPro;
    
                                    // Preline UI
                                    HSStaticMethods: IStaticMethods;
                                  }
                                }
    
                                export {};
                              
                            
  4. Add the Preline UI JavaScript

    Import and attach the required external libraries in project_root_directory/src/main.ts, then load Preline UI.

    main.ts
                              
                                ...
    
                                // Optional third-party libraries
                                import $ from "jquery";
                                import _ from "lodash";
                                import noUiSlider from "nouislider";
                                import "datatables.net";
                                import "dropzone/dist/dropzone-min.js";
                                import * as VanillaCalendarPro from "vanilla-calendar-pro";
    
                                window._ = _;
                                window.$ = $;
                                window.jQuery = $;
                                window.DataTable = $.fn.dataTable;
                                window.noUiSlider = noUiSlider;
                                window.VanillaCalendarPro = VanillaCalendarPro;
    
                                ...
    
                                app.mount("#app");
    
                                // Preline UI
                                import("preline/dist/index.js");
                              
                            
  5. Reinitialize with vue-router

    Re-run Preline UI initialization after route changes in project_root_directory/src/router/index.ts.

    index.ts
                              
                                import { createRouter, createWebHistory } from "vue-router";
    
                                import HomeView from "../views/HomeView.vue";
    
                                const router = createRouter({
                                  ...
                                  routes: [
                                    {
                                      path: "/",
                                      name: "home",
                                      component: HomeView,
                                    },
                                    ...
                                  ],
                                });
    
                                router.afterEach(async (to, from, failure) => {
                                  if (!failure) setTimeout(() => window.HSStaticMethods.autoInit(), 100);
                                });
    
                                export default router;
                              
                            
  6. Reinitialize without router

    Re-run Preline UI initialization when the app mounts in project_root_directory/src/App.vue.

    App.vue
                              
                                onMounted(() => {
                                  setTimeout(() => window.HSStaticMethods.autoInit(), 100)
                                });
                              
                            

Optional Preline UI styles

Preline UI ships with a small set of opinionated base styles that can be applied to components by default. If you want those defaults in your project, include them in your CSS. These styles shipped by default in Tailwind CSS v3, so they remain available as an optional layer in Preline UI.

CSS
                        
                          /* Adds pointer cursor to buttons */
                          @layer base {
                            button:not(:disabled),
                            [role="button"]:not(:disabled) {
                              cursor: pointer;
                            }
                          }

                          /* Defaults hover styles on all devices */
                          @custom-variant hover (&:hover);
                        
                      

© 2026 Preline Labs.