Setup
PrimeVue is a rich set of open source native components for Vue.
Download
PrimeVue is available at npm, if you have an existing application run the following commands to download PrimeVue and PrimeIcons to your project.
npm install primevue --save
npm install primeicons --save
Module Loader
This is the recommended way if your application uses vue-cli or has a webpack based build with vue-loader configured.
Import the components as .vue files for seamless integration within your project where path of each component is available at the "import" section of a component documentation.
//import ComponentName from 'primevue/componentname';
import Dialog from 'primevue/dialog';
In the next step, register the component with the tag name you'd like to use.
Vue.component('Dialog', Dialog);
Then you'll be able to utilize the component in your application.
<Dialog></Dialog>
Script Tag
Other alternative is utilizing the components directly within the browser with UMD packages.
<meta charset="utf-8">
<title>calendar demo</title>
<link href="https://unpkg.com/primevue/resources/themes/saga-blue/theme.css " rel="stylesheet">
<link href="https://unpkg.com/primevue/resources/primevue.min.css " rel="stylesheet">
<link href="https://unpkg.com/primeicons/primeicons.css " rel="stylesheet">
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/primevue/components/calendar/calendar.umd.min.js"></script>
<div id="app">
<p-calendar></p-calendar>
</div>
<script>
new Vue({
components: {
'p-calendar': calendar
}
}).$mount('#app')
</script>
Dependencies
Majority of PrimeVue components (95%) are native and there are some exceptions having 3rd party dependencies such as Quill for Editor.
In addition, components require PrimeIcons library for icons.
dependencies: {
"vue": "^2.6.10",
"primeicons": "^4.0.0"
}
Here is the list of components with 3rd party dependencies.
Component |
Dependency |
Charts |
Charts.js 2.1.x+ |
Editor |
Quill.js 1.3.3+ |
FullCalendar |
FullCalendar 4.0.2+. |
PrimeFlex |
DataView |
Styles
The css dependencies are as follows, note that you may change the theme with another one of your choice. If you are using a bundler such as webpack with a css loader you
may import them to your main application component.
primevue/resources/themes/saga-blue/theme.css //theme
primevue/resources/primevue.min.css //core css
primeicons/primeicons.css //icons
Free Themes
PrimeVue ships with 32 free themes to choose from, import paths are as follows.
primevue/resources/themes/bootstrap4-light-blue/theme.css
primevue/resources/themes/bootstrap4-light-purple/theme.css
primevue/resources/themes/bootstrap4-dark-blue/theme.css
primevue/resources/themes/bootstrap4-dark-purple/theme.css
primevue/resources/themes/md-light-indigo/theme.css
primevue/resources/themes/md-light-deeppurple/theme.css
primevue/resources/themes/md-dark-indigo/theme.css
primevue/resources/themes/md-dark-deeppurple/theme.css
primevue/resources/themes/mdc-light-indigo/theme.css
primevue/resources/themes/mdc-light-deeppurple/theme.css
primevue/resources/themes/mdc-dark-indigo/theme.css
primevue/resources/themes/mdc-dark-deeppurple/theme.css
primevue/resources/themes/saga-blue/theme.css
primevue/resources/themes/saga-green/theme.css
primevue/resources/themes/saga-orange/theme.css
primevue/resources/themes/saga-purple/theme.css
primevue/resources/themes/vela-blue/theme.css
primevue/resources/themes/vela-green/theme.css
primevue/resources/themes/vela-orange/theme.css
primevue/resources/themes/vela-purple/theme.css
primevue/resources/themes/arya-blue/theme.css
primevue/resources/themes/arya-green/theme.css
primevue/resources/themes/arya-orange/theme.css
primevue/resources/themes/arya-purple/theme.css
primevue/resources/themes/nova/theme.css
primevue/resources/themes/nova-alt/theme.css
primevue/resources/themes/nova-accent/theme.css
primevue/resources/themes/nova-vue/theme.css
primevue/resources/themes/luna-amber/theme.css
primevue/resources/themes/luna-blue/theme.css
primevue/resources/themes/luna-green/theme.css
primevue/resources/themes/luna-pink/theme.css
primevue/resources/themes/rhea/theme.css
Quickstart
An example application based on vue-cli is available at github.
Typescript
Typescript is fully supported as type definition files are provided in the npm package of PrimeVue. A sample typescript-primevue application is available as well at github.
Nuxt.js Integration
PrimeVue can easily be added to a Nuxt.js with the following steps.
1) Add primevue.js to the plugins folder with the components you'd like to use.
import Vue from 'vue';
import InputText from 'primevue/inputtext';
import Button from 'primevue/button';
import Toast from 'primevue/toast';
import ToastService from 'primevue/toastservice';
Vue.use(ToastService);
Vue.component('InputText', InputText);
Vue.component('Button', Button);
Vue.component('Toast', Toast);
2) Add requires CSS dependencies and the plugin configuration in nuxt.config.js.
css: [
{src: 'primevue/resources/primevue.min.css'},
{src: 'primevue/resources/themes/saga-blue/theme.css'},
{src: 'primeicons/primeicons.css'},
],
plugins: [
{src:'~/plugins/primevue.js', mode: 'client'}
]
That is all, for a complete example please refer to the primevue-nuxtjs-quickstart sample.