DEV Community

Cover image for The Definitive Guide to Vue UI Components
Chelsea Devereaux for MESCIUS inc.

Posted on • Originally published at Medium

The Definitive Guide to Vue UI Components

Vue.js is a framework for building modern web applications. It offers a complete set of features for enterprise developers to use, similar to what was formerly built in .NET or Java systems. Those same applications can now be built for the web and run on any device with a browser.

Vue is a powerful framework, but it does not include complex UI components. However, there are open-source and third-party options from which developers can choose. Vue UI Components are custom controls and tools that combine HTML elements, JavaScript (interaction), and CSS (style) to create a user-friendly interface for modern applications.

Technically, you can use HTML, JavaScript, and CSS to make any UI in a Vue application, but Vue UI components offer prebuilt components that are ready to use and will save a significant amount of effort and development time.

Why UI Components?

There are many reasons to use premade UI components. Let’s explore some of the most compelling.

Consistency — When using a set of UI components across an application (or even an entire company), you ensure that your user interface is consistent. Users are much more comfortable with consistent UI. You can also be sure that your components will behave in a predictable and stable way.

Saving Time — Another key benefit of using UI components is that they minimize development time. Complex UI can require significant effort to develop and maintain. By using a premade component, you can immediately build your application instead of spending time creating user interface elements from scratch.

Browser Support — Vast mobile and desktop browser support is another significant benefit of using UI components. Ensuring that components work consistently across all devices and browsers is challenging. When using premade components, you are leveraging what others have already established. Again, you benefit from UI components that have been thoroughly tested to work well in any environment.

Open-Source vs. Commercial UI Components

There are many high-quality open-source options for UI components. However, many tend to focus on layout and navigation rather than more complex components, like DataGrids and charts. Still, they remain an asset when building applications.

When developing more complex DataGrids, charts, and other elements, commercial UI components are usually the best option. You will receive high-quality components and full-service support by simply paying a license fee. For these business-critical components, many companies prefer a commercial option for peace of mind, knowing they will receive requested features, bug fixes, and issue resolution.

Both open-source and commercial options are not mutually exclusive. In fact, most of today’s enterprise applications use both!

The Top Five Custom Vue UI Components

We have analyzed our npm install data to find the most downloaded Vue UI components throughout our packages. Below are the five most popular components:

1. DataGrid

Not surprisingly, the Vue DataGrid is the most popular UI component. This component is used in some manner in nearly every application. DataGrids are a way of providing users with a manageable view of a large amount of data. They often contain many features and can be very powerful, making these components challenging to develop. So, most developers would rather purchase these than build their own. This component originated in the early days of programming and remains one of the most popular today. Read more about DataGrids in our Definitive Guide to Vue DataGrids.

Vue DataGrid

Vue DataGrid

2. Input

The second most popular are Input components. These are slightly simpler but still widely used. Again, most applications require inputs, and HTML only offers some basic options by default. Users have come to expect rich editors for different types of data. These Input components make applications much more user-friendly. Many input components can be found in open-source component libraries, like Bootstrap, but commercial libraries also typically include inputs.

Vue Input Components

Vue Input Components

3. OLAP (Pivot Components)

Next is OLAP Components, like PivotGrid and PivotChart. These are some of the most complex components since they enable the analytical processing of data. They are designed to provide end users with the ability to manipulate data and build their own views. The data is grouped and aggregated by the end user, essentially offering ad-hoc report building. These components aren’t prominent but are heavily used in specific business cases.

Vue PivotGrid and PivotChart OLAP Components

Vue PivotGrid and PivotChart OLAP Components

4. Charts

At number four are Chart components. Charts are not always a necessity, but when they are required, they are critical. Charts are used to convey information clearly, whereas text-based views do not. Charts, like DataGrids, are complex components and require much effort to develop. Similarly, most developers would prefer to purchase charts than build them on their own.

Various Vue Chart Types

Various Vue Chart Types

5. Navigation

Last but certainly not least are navigation components, like TreeView and TabPanel. These are easier to build from scratch but still require significant effort. Many developers choose open-source options for navigation functionality, but sometimes those don’t offer adequate features. In those instances, developers might opt to use commercial components.

Vue TreeView

Vue TreeView

How to Add Vue UI Components to Your Application

Since the most popular component is the DataGrid, let’s add one to our application. To start, we will assume you have an existing Vue app. You can create one easily by using something like the create-vue api.

Step 1: Install Packages from npm

To use the Vue FlexGrid, we must add the dependent packages from npm. The following command will install all the required packages.

npm install @mescius/wijmo.vue2.all
Enter fullscreen mode Exit fullscreen mode

Step 2: Import the Modules and Register the Component

Now that we have the required packages in our application, main.js, we will import the JavaScript and CSS modules and register the grid component so that we can use the Vue UI component in our <template>.

import { createApp } from 'vue' 
import App from './App.vue' 
import '@mescius/wijmo.styles/wijmo.css'; 
import {registerGrid} from "@mescius/wijmo.vue2.grid" 

let app = createApp(App); 
registerGrid(app); 
app.mount('#app') 
Enter fullscreen mode Exit fullscreen mode

Note: This is registering the grid at the application level, but you could also register it at the component level.

Step 3: Add Vue DataGrid Markup

In our component view (app.vue), we will add data and declare our Vue UI component in markup. The best Vue DataGrids are fully configurable in markup, including bindings, columns, and custom cell templates.

<script setup> 
import { ref } from 'vue' 
// variables 

const data = ref(getData()) 
//methods 

function getData() { 
  var data = [
        { id: 0, country: "US", sales: 1318.37, expenses: 4212.41 },
        { id: 1, country: "Germany", sales: 5847.95, expenses: 89.79 },
        { id: 2, country: "UK", sales: 502.55, expenses: 2878.50 },
        { id: 3, country: "Japan", sales: 4675.40, expenses: 488.65 },
        { id: 4, country: "Italy", sales: 2117.57, expenses: 925.60 },
        { id: 5, country: "Greece", sales: 322.10, expenses: 4163.96 }
    ]; 
  return data; 
} 
</script> 

<template> 
  <wj-flex-grid :itemsSource="data"></wj-flex-grid> 
</template> 
Enter fullscreen mode Exit fullscreen mode

Step 4: Run the App

That’s it! Just run your application and see your Vue UI component in action. Your grid will already support sorting, editing, selection, and more.

Run app

Themes for UI Components

As mentioned earlier, consistency is a benefit of using UI components. Most UI component libraries offer multiple themes from which developers can choose. These themes will style all components with a similar set of colors, fonts, etc. Simply by changing a theme, you can redesign your entire application when using UI components.

Custom theme builder for Material Design<br>

Custom theme builder for Material Design

Conclusion

The Vue framework is one of the best options for building fast software applications that run anywhere, and Vue UI components are an essential feature for the rapid development cycle. When you combine open-source Vue components with third-party Vue UI components, you can efficiently achieve all of your application requirements. Pick and choose what works for you, but leveraging existing components will always be a wise choice.

Top comments (0)