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

Install Preline UI with Hugo using Tailwind CSS

Install Preline UI with Tailwind CSS in Hugo projects, including JavaScript plugin setup, Hugo Pipes, static scripts, and optional dependencies.

Installation

Please note that the plugin has been tested with the 0.147.3 version of the framework. The framework was installed using the standard hugo new site <project-name> command.
If you are using your own project structure or a different version, pay attention to the file paths and features of your version!

Hugo quick setup

Start with a working Hugo site, then add Tailwind CSS before importing Preline UI.

Some components rely on third-party libraries. The setup below assumes full Preline UI usage with those dependencies preloaded. If you do not plan to use those components, you can remove the related libraries from your configuration.

  1. Install Preline UI

    Install preline, then copy the package assets into static/preline so Hugo can serve them.

    Terminal
                              
                                npm install preline
                                cp -r node_modules/preline static/preline
                              
                            

    Preline UI uses the Tailwind CSS Forms plugin across form components. Install it if you have not already: npm install -D @tailwindcss/forms

  2. Set up Tailwind CSS

    Install Tailwind CSS and its PostCSS integration package.

    Terminal
                              
                                npm install tailwindcss @tailwindcss/postcss
                              
                            

    Create a tailwind.config.js file in the project root and include your Hugo layout, content, and asset paths.

    tailwind.config.js
                              
                                /** @type {import('tailwindcss').Config} */
    
                                module.exports = {
                                  content: [
                                    './layouts/**/*.html',
                                    './content/**/*.md',
                                    './assets/**/*.js'
                                  ],
                                  theme: {
                                    extend: {}
                                  },
                                  plugins: []
                                };
                              
                            
  3. Set up PostCSS

    Install PostCSS, the CLI, and Autoprefixer.

    Terminal
                              
                                npm install postcss postcss-cli autoprefixer
                              
                            

    Create a postcss.config.js file in the project root.

    postcss.config.js
                              
                                module.exports = {
                                  plugins: {
                                    '@tailwindcss/postcss': {},
                                    autoprefixer: {}
                                  }
                                };
                              
                            
  4. Include Preline CSS

    Import Preline into projects_root_directory/assets/css/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.

  5. Run the Tailwind build

    Run the Tailwind CSS build task.

    Terminal
                              
                                npx @tailwindcss/cli -i ./assets/css/main.min.css -o ./static/css/main.css --minify --watch
                              
                            
  6. Load scripts in the base layout

    Add the stylesheet and script tags in projects_root_directory/layouts/_default/baseof.html.

    baseof.html
                              
                            

    If you use any optional third-party scripts, load them in baseof.html before the Preline UI script. Copy those files from node_modules into your static/vendor directory first.

Optional Preline UI styles

Preline UI ships with a small set of opinionated base styles. If you want them in your project, add them to your CSS file. These defaults used to come bundled with Tailwind CSS v3, so they are still 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.