Installation
Setting up Preline UI in a Vue.js project using Tailwind CSS.
Please note that the plugin has been tested with the latest version of the framework (v3.3.4). The framework was installed using the standard npm create vue@latest
command.
If you are using your own project structure, be mindful of file paths!
The Progressive JavaScript Framework. If you haven't set up Tailwind CSS yet, check out Vue Tailwind CSS installation guides.
Install preline
via npm or yarn.
// Terminal or Shellnpm 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'), ],}
Add the Preline UI JavaScript in your app entry point projects_root_directory/src/main.ts|js
import "preline/preline";
Add code that reinitializes the components every time the page is refreshed to your "route" projects_root_directory/src/router/index.ts|js
import { createRouter, createWebHistory } from 'vue-router'
...
const router = createRouter({
...
});
router.afterEach((to, from, failure) => {
if (!failure) {
setTimeout(() => {
HSStaticMethods.autoInit();
}, 100)
}
});
export default router;
Add code that reinitializes the components every time when app is mounted projects_root_directory/src/App.vue
<script setup>
import { onMounted } from 'vue';
onMounted(() => {
setTimeout(() => {
HSStaticMethods.autoInit();
}, 100)
});
</script>
...