Installation
Setting up Preline UI in a Nuxt.js project using Tailwind CSS.
Please note that the plugin has been tested with the latest version of the framework (v3.8.1). The framework was installed using the standard npx nuxi@latest init <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!
The Intuitive Web Framework. If you haven't set up Tailwind CSS yet, check out Nuxt.js Tailwind CSS installation guides.
Install preline
via npm or yarn.
npm install preline // or yarn add preline
Add the path to Preline UI JavaScript files in your tailwind.config.js
file.
// tailwind.config.jsmodule.exports = { content: [ './node_modules/preline/preline.js', ], plugins: [ require('preline/plugin'), ],}
Create the Preline UI JavaScript loader inside the project, e.g. projects_root_directory/plugins/preline.client.ts
import "preline/preline";
import { type IStaticMethods } from "preline/preline";
declare global {
interface Window {
HSStaticMethods: IStaticMethods;
}
}
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook("page:finish", () => {
window.HSStaticMethods.autoInit();
});
});
Include Preline UI JavaScript loader to the nuxt.config.js
file.
export default defineNuxtConfig({
...
plugins: ["~/plugins/preline.client.ts"],
});