Skip to content
Tutorials Center
My learning

Topics

Lesson 71 of 87 ยท Performance, Security and Ecosystem

Component Libraries: Vuetify, PrimeVue, Element Plus

Choose and use a Vue 3 UI library: compare Vuetify, PrimeVue, Element Plus and headless options, install them, theme with design tokens, keep bundles small with tree-shaking and check accessibility.

Buttons, dialogs, date pickers, data tables, menus: every application needs them, and building them well is hard. A date picker alone has to handle keyboards, screen readers, time zones, locales and touch. A component library gives you hundreds of these parts ready-made, so you spend your time on your product.

The three most popular choices for Vue 3 are Vuetify, PrimeVue and Element Plus. Each is a different bet about design, size and flexibility. This lesson compares them, shows the setup pattern they share, and explains the decisions that matter more than any feature list: theming, bundle size and accessibility. You can read the setup code, but the libraries cannot be installed in the sandbox, so the runnable examples teach the ideas with small hand-made components.

The main options at a glance

Library Look and feel Strengths Think about
Vuetify Google's Material Design Very complete, consistent, strong layout system and theming, large community A strong visual identity: customizing away from Material takes effort
PrimeVue Several themes (Aura, Lara, Material) or fully unstyled Huge component set including a powerful DataTable, charts and a theme designer Many components can mean many choices; check licences of any paid extras
Element Plus Clean business/admin style Excellent forms, tables and admin dashboards, popular in enterprise apps Less suited to a very custom, brand-led design
Naive UI, Quasar Naive: modern and TypeScript-first. Quasar: a whole framework for web, mobile and desktop Good alternatives Quasar wants to own your build setup
Headless (Reka UI, Headless UI) None: you write the CSS Accessible behaviour without visual opinions, perfect for a custom design system You build all the styling yourself

There is no best library, only the best fit. For an internal dashboard where speed matters and the design does not need to be unique, Element Plus or PrimeVue will get you there fast. For an app that should feel like Material, Vuetify. For a brand-specific design system with a small team, consider a headless library plus your own styles, or Tailwind-based kits (styling strategies).

Installing: the shared pattern

All of them follow the same four steps: install the package, register it as a plugin in main.js, import its styles, then use its components. These snippets are read-only:

JavaScript
// Vuetify 3 (with vite-plugin-vuetify, components are imported automatically)
import { createApp } from "vue";
import { createVuetify } from "vuetify";
import "vuetify/styles";
import App from "./App.vue";

const vuetify = createVuetify({
  theme: {
    defaultTheme: "light",
    themes: { light: { colors: { primary: "#1867C0", secondary: "#5CBBF6" } } },
  },
});
createApp(App).use(vuetify).mount("#app");
JavaScript
// PrimeVue 4: pick a theme preset
import PrimeVue from "primevue/config";
import Aura from "@primeuix/themes/aura";

createApp(App).use(PrimeVue, { theme: { preset: Aura } }).mount("#app");
JavaScript
// Element Plus: styles for the full library (see tree-shaking below for the leaner way)
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";

createApp(App).use(ElementPlus).mount("#app");

Then, in a template, using each library looks natural for Vue:

VUE
<template>
  <v-btn color="primary" @click="save">Save</v-btn>            <!-- Vuetify -->
  <Button label="Save" severity="success" @click="save" />      <!-- PrimeVue -->
  <el-button type="primary" @click="save">Save</el-button>      <!-- Element Plus -->
</template>

Notice what these have in common with the components you write yourself: props configure them, events report what happened, slots customize the content, and v-model binds form fields (component v-model). A library is just well-made components, so everything you learned about props, emits and slots applies.

Theming: design tokens and CSS variables

Every library lets you change colours, radii and fonts without editing its source. The mechanism is design tokens: named values (primary, border-radius, font-size-base) that the components read, almost always through CSS custom properties. Element Plus exposes --el-color-primary; Vuetify turns theme colours into variables such as --v-theme-primary; PrimeVue presets generate --p-primary-color and friends. Change the variable and every component that uses it follows, including dark mode, which is usually a second set of values.

The demo builds a mini library of two components that read tokens from CSS variables. Switching the theme changes one container's variables, and nothing inside the components.

Theming with design tokens (a mini component library)

Switch between the three themes: colours, corner radius and the dark variant all change, but LButton and LTag have no theme code. This is exactly how Element Plus, Vuetify and PrimeVue let you re-brand an app. When you customize a library, change tokens first, add a few overrides second, and avoid fighting the component's internal CSS with !important, which breaks on every upgrade. Scoped styles do not reach inside a child component's elements, so use the library's documented props, slots and variables; see scoped CSS for the :deep() escape hatch and its costs.

Keeping the bundle small: tree-shaking and on-demand imports

A UI library can be huge. Importing it wholesale (app.use(ElementPlus)) ships every component, including the ones you never use. Three techniques bring that down:

  1. Import only what you use. With PrimeVue, import Button from "primevue/button" registers one component. Element Plus and PrimeVue both ship ES modules designed for tree-shaking.
  2. Auto-import with a build plugin. unplugin-vue-components scans your templates and imports components on demand, using a resolver for each library (ElementPlusResolver, PrimeVueResolver, VuetifyResolver). vite-plugin-vuetify does the same for Vuetify.
  3. Lazy-load heavy components such as editors, data grids and charts with defineAsyncComponent (build and load performance).

Check the result instead of guessing: run npm run build and inspect the output sizes, or use a bundle visualizer. A library's CSS is often bigger than its JavaScript; importing per-component styles or using a plugin that does so helps too.

Accessibility: a library does not make your app accessible

Good libraries implement correct keyboard handling, focus management and ARIA roles for complex widgets (menus, dialogs, comboboxes). That is a real advantage over writing them yourself. But accessibility is shared work. You still must provide labels, alt text, sensible heading order and colour contrast, and you must test with a keyboard. Libraries differ in quality here, so test the components you will use most; for custom-designed systems, headless libraries are attractive because they give you the behaviour without forcing a look.

The second demo shows what "behaviour without a look" means. A headless menu handles open/close, aria-expanded, role="menu" and arrow-key navigation, and the parent decides what it looks like through a scoped slot.

A headless menu: accessibility logic without styling

Open the menu and use the arrow keys: the highlighted row moves, Enter selects, Escape closes, and the trigger announces aria-expanded to screen readers. All of that lives in HeadlessMenu; the <ul> and its classes belong to the page, so a second design (for example the pill styles) would reuse the same behaviour. This is the model behind Reka UI and Headless UI, and it is the same scoped-slot technique from Slots.

How to choose: a checklist

  • Design fit. Does your design resemble the library's (Material, business admin, neutral)? If not, plan for token customization or choose headless.
  • Components you really need. List the three hardest widgets (data table, date range picker, tree select, charts) and check them in the demo site of each candidate, on a phone and with the keyboard.
  • TypeScript and Vue 3 support. Look for types, regular releases and clear Vue 3.5 and Nuxt compatibility.
  • Bundle cost. Build a small page with your three hardest components and measure.
  • Accessibility and i18n. Check ARIA behaviour and locales (internationalization); right-to-left support varies.
  • Licence and maintenance. Look at the licence (some extras are paid), how fast issues are answered and how breaking major releases are handled.
  • Exit cost. Wrap library components in your own thin components (AppButton, AppSelect) for the ones you use everywhere (component design). If you ever switch libraries, you change a handful of files, not hundreds of templates.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which approach best keeps a UI library's bundle small?

    On-demand imports let the bundler drop unused components. Auto-import plugins do this from your templates, and defineAsyncComponent defers heavy widgets.
  2. 2. How are themes in Vuetify, PrimeVue and Element Plus mostly implemented?

    Components use named tokens (colours, radii, fonts). Changing the token values re-themes every component, including dark mode.
  3. 3. What does a headless component library provide?

    Headless components deliver the logic and let you supply the markup and CSS, which suits custom design systems.
  4. 4. You use a library whose dialog is accessible. Is your app automatically accessible?

    A library handles widget behaviour, but content, labels and overall structure are still yours.
  5. 5. Why wrap library components in your own AppButton or AppSelect?

    A thin wrapper concentrates the library dependency in a few files, so swapping or re-skinning is a small change.

Summary

  • Vuetify (Material), PrimeVue (many components and themes) and Element Plus (business UI) are the main Vue 3 libraries; headless libraries give behaviour without styling.
  • Setup is always: install, app.use(...), import styles, use components in templates.
  • Theme through design tokens (CSS variables); avoid overriding internals with !important.
  • Keep bundles small with on-demand imports, auto-import plugins and lazy-loaded heavy components, and measure with a build.
  • A library implements widget accessibility but does not replace your own labels, contrast and testing.
  • Wrap frequently used components in your own to keep the exit cost low.

Next: upgrading an older codebase, Migrating from Vue 2 and Vuex.