Preline UI - Tailwind CSS component library
Quickly set up Preline UI for Tailwind CSS with installation docs, JavaScript setup, component examples, themes, and framework guides.
Quick setup
This guide will help you get started with Preline UI, including how to run, customize, update, and integrate your project!
First, you need to make sure that you have a working Tailwind CSS project installed and that you also have Node and NPM installed on your machine.
Require via NPM
-
Install Preline UI
Install
prelinevia npmTerminalnpm i prelinePlease 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 -
Add the Preline UI CSS Variants
Use @source Preline UI JavaScript path and @import CSS Variants file
variants.cssinto your Tailwind CSS file, ensuring it comes after thetailwindcssimport.main.css@import "tailwindcss"; /* Preline UI */ /* [!code highlight:2] */ @source "./node_modules/preline/dist/*.js"; @import "./node_modules/preline/variants.css"; /* Plugins */ @plugin "@tailwindcss/forms"; /* Preline Themes */ @import "./themes/theme.css";Check out the Theme docs to learn more about Preline Themes.
-
Add the Preline UI JavaScript
Include the JavaScript
<script>that powers the interactive elements near the end of your</body>tag:HTML
Additional Initialization Options
Use the
non-autoentry if you need manual initialization or selective imports. In this mode, automatic initialization of elements on page load is not included, so components should be initialized explicitly (for example, withnewor via static methods).HTML (non-auto)HTML (single plugin)The above example refers to dropdown, you may apply the same approach to other plugins.
Framework Guides
Preline UI comes with some framework-specific guides to help you get started with the library.
Check out Framework Guides
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.
/* 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);
What's Preline UI?
It's an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
Why use Preline UI?
Based on the Tailwind CSS utility classes, Preline UI's prebuilt components and UI elements help you quickly design and customize responsive mobile-first websites with diverse predefined components (such as modals, buttons, alerts, cards and more).
What's in the box?
Components are grouped by visual usability criteria (components, navigation, forms, etc.) and styled directly on top of Tailwind CSS, making them easy to extend and customize. This is a lifesaver for developers looking to create a unique and eye-catching design system without the hassle of creating each component by hand.