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

Install Preline UI with Solid.js using Tailwind CSS

Install Preline UI with Tailwind CSS in Solid.js projects, including JavaScript plugin setup, router rescans, app initialization, and optional dependencies.

Installation

Please note that the plugin has been tested with the 1.9.5 version of the framework. The framework was installed using the standard npx degit solidjs/templates/ts <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!

Solid.js quick setup

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

Preline UI + Solid.js

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 with your preferred package manager.

    Terminal
                              
                                npm install 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. Include Preline CSS

    Import Preline into projects_root_directory/src/index.css.

    index.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";
                              
                            

    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 projects_root_directory/src/global.d.ts.

    global.d.ts
                              
                                import type noUiSlider from "nouislider";
                                import type { IStaticMethods } from "preline/dist";
    
                                declare global {
                                  interface Window {
                                    // Optional third-party libraries
                                    _: typeof import("lodash");
                                    $: typeof import("jquery");
                                    jQuery: typeof import("jquery");
                                    DataTable: typeof $.fn.dataTable;
                                    Dropzone: typeof import("dropzone");
                                    noUiSlider: typeof noUiSlider;
                                    VanillaCalendarPro: typeof import("vanilla-calendar-pro");
    
                                    // Preline UI
                                    HSStaticMethods: IStaticMethods;
                                  }
                                }
    
                                export {};
                              
                            
  4. Add Preline UI to the app entry

    Import and attach the required external libraries in projects_root_directory/src/index.tsx, then load Preline UI before rendering the app.

    index.tsx
                              
                                ...
    
                                // 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;
    
                                const root = document.getElementById('root');
    
                                ...
    
                                // Preline UI
                                import("preline/dist").then(() => {
                                  render(() => <App />, root!);
                                });
                              
                            
  5. Reinitialize on route changes

    Re-run Preline UI initialization when the app mounts or the route changes in projects_root_directory/src/App.tsx.

    App.tsx
                              
                                import { createSignal, createEffect } from 'solid-js';
                                import type { Component } from 'solid-js';
                                import { useLocation } from '@solidjs/router';
    
                                ...
    
                                const App: Component = () => {
                                  const location = useLocation();
                                  const [_, setLoc] = createSignal(location.pathname);
    
                                  createEffect(() => {
                                    setLoc(location.pathname);
    
                                    window.HSStaticMethods.autoInit();
                                  });
    
                                  return (
                                    ...
                                  );
                                };
    
                                export default App;
                              
                            

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.