1. Frameworks
  2. HTML + Vite

Installation

Install Preline UI with HTML + Vite using Tailwind CSS

Setting up Preline UI in a HTML + Vite project using Tailwind CSS.

Installation

Please note that the plugin has been tested with HTML and 7.1.2 version of the Vite. The framework was installed using the npm create vite@latest <project name> -- --template vanilla-ts command.
If you are using your own project structure or a different version, pay attention to the file paths and features of your version!

Quick HTML + Vite setup

If you haven't set up Tailwind CSS yet, check out HTML + Vite Tailwind CSS installation guides.

Preline UI + HTML + Vite

Some components require third-party libraries. The settings below assume full use of Preline UI, including preloaded dependencies. If you do not intend to use those components that rely on third-party libraries, you may exclude them from your configuration.

  1. Install Preline UI

    Install Preline using your preferred package manager.

    Terminal
                          
                            npm install preline
                          
                        

    Please note, Preline UI uses Tailwind CSS Forms plugin in all form components. Don't forget to install it, if you haven't done so already: npm install -D @tailwindcss/forms

  2. Include Preline CSS

    Include Preline in your style.css file, e.g. projects_root_directory/src/style.css

    style.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"; */
    
                            /* Plugins */
                            /* @plugin "@tailwindcss/forms"; */
    
                            /* Preline Themes */
                            @import "./themes/theme.css";
                          
                        

    Check out the Theme docs to learn more about Preline Themes.

  3. Add Preline JS

    Include Preline on every HTML page.

    index.html
                          
                        
  4. Using Preline UI

    Pay attention to the quotes inside data attributes when adding them to the page with Vite.

    main.ts
                          
                        

Optional Preline UI Styles

Please note, Preline UI comes with some opinionated styles that are applied to components by default. If you want these styles in your project, you may include them into your CSS file. These styles used to come by default in Tailwind v3, so we decided to keep them 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);
                    
                  

Community Workarounds

Check out this section for community-shared tips and tricks. It's a spot for finding those handy hacks and solutions that enhance your experience with Preline UI.