vue.js logo

Install PrimeVue in your Vue.js project


Step 1: Install PrimeVue and PrimeIcons

You can install PrimeVue, PrimeIcons, and optionally, a theme using npm or yarn.


Using npm: npm install primevue primeicons


Using yarn: yarn add primevue primeicons


Step 2: Configure PrimeVue

To use PrimeVue components, you need to configure it in your Vue.js project.


1. Create a PrimeVue Plugin: Create a file named `primevue.js` in the `src/plugins` directory (create the directory if it doesn't exist).



      import Vue from 'vue';
      import PrimeVue from 'primevue/config';
      import 'primevue/resources/themes/saga-blue/theme.css'; // or any other theme
      import 'primevue/resources/primevue.min.css';
      import 'primeicons/primeicons.css';

      Vue.use(PrimeVue);

2. Update main.js: Import and use the PrimeVue plugin in your `main.js` file.


    import Vue from 'vue';
    import App from './App.vue';
    import router from './router';
    import store from './store';
    import PrimeVue from './plugins/primevue'; // import the PrimeVue plugin

    Vue.config.productionTip = false;

    new Vue({
      router,
      store,
      render: h => h(App)
      }).$mount('#app');

Step 3: Additional Configuration:

You can also configure global settings and default options for PrimeVue components. For example:



    import Vue from 'vue';
    import PrimeVue from 'primevue/config';
    import 'primevue/resources/themes/saga-blue/theme.css';
    import 'primevue/resources/primevue.min.css';
    import 'primeicons/primeicons.css';

    Vue.use(PrimeVue, { ripple: true });

That's it! You have successfully installed PrimeVue in your Vue.js project.