Go to file
Cagatay Civici e5f970aee6 Merge branch 'master' of https://github.com/primefaces/primevue 2023-03-20 13:04:31 +03:00
.github Apidoc workflow added 2023-03-08 11:23:47 +03:00
.vscode update .vscode 2022-12-19 13:52:02 +03:00
api-generator Fixed #3753 - ConfirmDialog: Add draggable property 2023-03-16 17:37:09 +03:00
assets Fixed material light theme switch, cosmetics on docs 2023-03-20 13:04:29 +03:00
components Toast `life` default value fixed 2023-03-20 11:45:08 +03:00
doc Update API doc 2023-03-20 08:46:02 +00:00
layouts Merge branch 'master' of https://github.com/primefaces/primevue 2023-03-20 13:04:31 +03:00
middleware landing scroll top fix 2022-12-28 12:32:27 +03:00
pages Fixed material light theme switch, cosmetics on docs 2023-03-20 13:04:29 +03:00
plugins storageKey added 2023-03-08 12:58:44 +03:00
public astro images added 2023-03-15 11:30:10 +03:00
service Merged new Docs and Demos 2023-02-28 11:29:30 +03:00
.eslintrc.js Update .eslintrc.js 2023-02-28 10:51:46 +00:00
.gitignore update for new free 6 themes 2023-01-27 14:56:16 +03:00
.prettierignore prettier warnings fixed 2022-12-20 15:32:32 +03:00
.prettierrc.json Lint changes 2022-09-14 17:26:41 +03:00
CHANGELOG.md Update CHANGELOG.md 2023-03-13 16:43:38 +03:00
LICENSE.md Merged new Docs and Demos 2023-02-28 11:29:30 +03:00
README.md Contributors added to readme 2023-03-13 14:15:48 +03:00
app.vue Add docsearch 2023-03-04 20:18:40 +03:00
build-meta.js Changes for package build 2022-09-14 17:49:38 +03:00
gulpfile.js update for new free 6 themes 2023-01-27 14:56:16 +03:00
nuxt.config.js Remove @vitejs/plugin-vue-jsx package 2023-03-03 10:32:47 +03:00
package-build.json set new version 2023-03-14 09:12:31 +03:00
package-lock.json InputText Vee-Validate demo added 2023-03-15 17:50:39 +03:00
package.json InputText Vee-Validate demo added 2023-03-15 17:50:39 +03:00
rollup.config.js prettier warnings fixed 2022-12-20 15:32:32 +03:00
tsconfig.json Merged new Docs and Demos 2023-02-28 11:29:30 +03:00
vitest.config.js Merge branch 'master' into resolves-fix 2023-01-03 21:16:28 +01:00

README.md

License: MIT npm version Discord Chat

PrimeVue Hero

PrimeVue

PrimeVue is a rich set of open source UI Components for Vue. See PrimeVue homepage for live showcase and documentation.

Download

PrimeVue is available at npm, if you have an existing application run the following command to download it to your project.

npm install primevue --save
npm install primeicons --save

or

yarn add primevue
yarn add primeicons

Next step is setting up PrimeVue configuration.

import {createApp} from 'vue';
import App from './App.vue';
import PrimeVue from 'primevue/config';
const app = createApp(App);

app.use(PrimeVue);

Import

Module

import {createApp} from 'vue';
import App from './App.vue';
import PrimeVue from 'primevue/config';
import Dialog from 'primevue/dialog';
const app = createApp(App);

app.use(PrimeVue);

app.component('Dialog', Dialog);

Finally you'll be able to utilize the component in your application. See the Styles section to apply styling.

<Dialog></Dialog>

CDN

<script src="https://unpkg.com/primevue/core/core.min.js"></script>
<script src="https://unpkg.com/primevue/multiselect/multiselect.min.js"></script>

Single File Components

SFC files are available in the npm distribution and if you'd like to use SFCs directly, add /sfc as a suffix when referencing an import path. This will instruct your bundler to process the *.vue files in your local build instead of using the compiled output. One use case for this approach is optimizing for SSR by removing whitespaces.

import Dialog from 'primevue/dialog/sfc';

Script Tag

Other alternative is utilizing the components directly within the browser with the iife build. Note that PrimeVue does not provide a umd build.

<html>
    <head>
        <meta charset="utf-8">
        <title>PrimeVue Demo</title>
        <link href="https://unpkg.com/primevue/resources/themes/lara-light-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@next"></script>
        <script src="https://unpkg.com/primevue/core/core.min.js"></script>
        <script src="https://unpkg.com/primevue/slider/slider.min.js"></script>
    </head>

    <body>
        <div id="app">
            <p-slider v-model="val"></p-slider>
            <h6>{{val}}</h6>
        </div>

        <script>
            const {createApp, ref} = Vue;

            const App = {
                setup() {
                    const val = ref(null);

                    return {
                        val
                    };
                },
                components: {
                    'p-slider': primevue.slider
                }
            };

            createApp(App).use(primevue.config.default).mount("#app");
        </script>
    </body>
</html>

Styles

The css dependencies are as follows, note that you may change the theme with another one of your choice.

primevue/resources/themes/lara-light-blue/theme.css       //theme
primevue/resources/primevue.min.css                 //core css
primeicons/primeicons.css                           //icons

If you are using a bundler such as webpack with a css loader you may also import them to your main application component.

import 'primevue/resources/themes/lara-light-blue/theme.css';
import 'primevue/resources/primevue.min.css';
import 'primeicons/primeicons.css';

Nuxt Integration

Nuxt 3 is currently in beta and an official module is planned after the final release. At the moment, PrimeVue can easily be used with Nuxt 3 using a custom plugin.

nuxt.config.js

Open the nuxt configuration file and add the css dependencies.

import { defineNuxtConfig } from 'nuxt3';

export default defineNuxtConfig({
    css: [
        'primevue/resources/themes/lara-light-blue/theme.css',
        'primevue/resources/primevue.css',
        'primeicons/primeicons.css'
    ]
})

primevue.js

Create a file like primevue.js under the plugins directory for the configuration.

import { defineNuxtPlugin } from "#app";
import PrimeVue from "primevue/config";
import Button from "primevue/button";

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.use(PrimeVue, {ripple: true});
    nuxtApp.vueApp.component('Button', Button);
    //other components that you need
});

Configuration

Dependencies

PrimeVue components are not wrappers and implemented natively with the Vue APIs. There are some exceptions having 3rd party dependencies such as Quill for Editor.

In addition, components require PrimeIcons library for icons.

dependencies: {
    "vue": "^3.0.0",
    "primeicons": "^6.0.0"
}

Prop Cases

Component prop names are described as camel case throughout the documentation however camel-case is also fully supported. Events on the other hand should always be camel-case.

<Dialog :showHeader="false"></Dialog>

<!-- can be written as -->

<Dialog :show-header="false"></Dialog>

Ripple

Ripple is an optional animation for the supported components such as buttons. It is disabled by default and needs to be enabled at your app's entry file (e.g. main.js) during the PrimeVue setup.

import {createApp} from 'vue';
import PrimeVue from 'primevue/config';
const app = createApp(App);

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

Outlined vs Filled Input Styles

Input fields come in two styles, default is outlined with borders around the field whereas filled alternative adds a background color to the field. Applying p-input-filled to an ancestor of an input enables the filled style. If you prefer to use filled inputs in the entire application, use a global container such as the document body or the application element to apply the style class. Note that in case you add it to the application element, components that are teleported to the document body such as Dialog will not be able to display filled inputs as they are not a descendant of the application root element in the DOM tree, to resolve this case set inputStyle to 'filled' at PrimeVue configuration as well.

import {createApp} from 'vue';
import PrimeVue from 'primevue/config';
const app = createApp(App);

app.use(PrimeVue, {inputStyle: 'filled'});

ZIndex Layering

ZIndexes are managed automatically to make sure layering of overlay components work seamlessly when combining multiple components. Still there may be cases where you'd like to configure the configure default values such as a custom layout where header section is fixed. In a case like this, dropdown needs to be displayed below the application header but a modal dialog should be displayed above. PrimeVue configuration offers the zIndex property to customize the default values for components categories. Default values are described below and can be customized when setting up PrimeVue.

import {createApp} from 'vue';
import PrimeVue from 'primevue/config';
const app = createApp(App);

app.use(PrimeVue, {
    zIndex: {
        modal: 1100,        //dialog, sidebar
        overlay: 1000,      //dropdown, overlaypanel
        menu: 1000,         //overlay menus
        tooltip: 1100       //tooltip
    }
});

Locale

PrimeVue provides a Locale API to support i18n and l7n, visit the Locale documentation for more information.

Quickstart with Vue CLI

An example application based on Vue CLI is available at github.

Quickstart with Vite

A starter application is also provided for Vite users.

Quickstart with Nuxt

A sample application is created for Nuxt 3 users.

Quickstart with TypeScript

Typescript is fully supported as type definition files are provided in the npm package of PrimeVue. A sample typescript-primevue application with Vue CLI is available as at github.

Contributors