<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vishnuraj Sivakumar</title>
    <description>The latest articles on DEV Community by Vishnuraj Sivakumar (@vishnubhadri).</description>
    <link>https://dev.to/vishnubhadri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F565375%2F6db35600-6db6-4641-b4ec-c13ec7a14a42.jpeg</url>
      <title>DEV Community: Vishnuraj Sivakumar</title>
      <link>https://dev.to/vishnubhadri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vishnubhadri"/>
    <language>en</language>
    <item>
      <title>Bringing Icons to Life in Vue.js with the Dynamic 'vivid-icon' Component</title>
      <dc:creator>Vishnuraj Sivakumar</dc:creator>
      <pubDate>Sat, 28 Jan 2023 04:44:26 +0000</pubDate>
      <link>https://dev.to/vishnubhadri/bringing-icons-to-life-in-vuejs-with-the-dynamic-vivid-icon-component-902</link>
      <guid>https://dev.to/vishnubhadri/bringing-icons-to-life-in-vuejs-with-the-dynamic-vivid-icon-component-902</guid>
      <description>&lt;p&gt;Are you building a Vue.js application and looking for a way to easily display and customize icons? Look no further than the "vivid-icon" component.&lt;/p&gt;

&lt;p&gt;Before diving into the implementation of the "vivid-icon" component you need to understand how to import svg in vue+vuetify. you can find the official documentation from vuetify &lt;a href="https://vuetifyjs.com/en/features/icon-fonts/#using-custom-icons" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The "vivid-icon" component is based on Vue's built-in "v-icon" component, but extends its functionality by allowing you to customize the color, fill, and stroke of the icon. This is achieved through the use of props:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vivid-icon&lt;/code&gt; were written on top of the &lt;code&gt;v-icon&lt;/code&gt; (a vuetify component) to support both icon and svg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
    &amp;lt;v-icon v-bind="$attrs" v-on="$listeners" :color="color"
        :class="computedFill || computedStroke || computedColor ? `vivid-icon__f${computedFill}_s${computedStroke}_c${computedColor} vivid-icon` : ''"&amp;gt;
        &amp;lt;slot /&amp;gt;
    &amp;lt;/v-icon&amp;gt;
&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;props: {
    color: { default: '' },
    fill: { default: '' },
    stroke: { default: '' },
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But how exactly does this component change the appearance of the icon? The component uses two utility functions, createCssVariableScoped() and updateCssVariablesScoped() to create and update CSS variables that are used to style the icon. These functions are defined in the script section of the component, and allow the component to dynamically update the appearance of the icon based on the values of its props.&lt;/p&gt;

&lt;p&gt;The createCssVariableScoped() function takes four arguments: properties, cssClass, element, and additionalClass. It creates a new style tag, sets its id attribute to the concatenation of the cssClass and the componentId, and sets its type attribute to "text/css". It then creates a new style using properties and additionalClass and sets it as the innerText of the style tag. Finally, it returns the style tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createCssVariableScoped(
    properties,
    cssClass,
    element,
    additonalClass
) {
    let componentId = element.attributes[0].name
    let styleTag = document.createElement('style')
    styleTag.id = cssClass + componentId
    styleTag.setAttribute('type', 'text/css')
    let style = `.${cssClass}${additonalClass}{
           ${properties}
          }`

    styleTag.innerText = style
    return styleTag
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The updateCssVariablesScoped() function takes four arguments: updatedStyle, cssClass, element, and additionalClass. It first retrieves the componentId from the element attributes. It then creates a new style using updatedStyle and additionalClass and sets it as the innerText of the style tag with the id of cssClass + componentId. If the tag is already present it will remove the existing one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function updateCssVariablesScoped(
    updatedStyle,
    cssClass,
    element,
    additonalClass
) {
    let componentId = element.attributes[0].name
    let style = `.${cssClass}${additonalClass} {
        ${updatedStyle}
    }`

    document
        .querySelectorAll('#' + cssClass + componentId)
        .forEach((item, length) =&amp;gt; {
            if (length &amp;gt; 0) {
                item.remove()
            }
        })
    document.getElementById(cssClass + componentId).innerText = style
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And are used in the component's "mounted" lifecycle hook to create a style tag that contains the CSS variables and to update the variables when the "color", "fill", or "stroke" props change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mounted() {
        if (this.stroke || this.fill || this.color) {
            let props = `stroke: ${this.stroke ? this.stroke : "inherit"};fill: ${this.fill ? this.fill : "inherit"};color: ${this.color ? this.color : "inherit"};`;

            let additionalClass = `.vivid-icon__f${this.computedFill}_s${this.computedStroke}_c${this.computedColor} .vivid-icon--color`;


            this.styleTag = createCssVariableScoped(
                props,
                "vivid-icon",
                this.$el,
                additionalClass
            );
            document.head.appendChild(this.styleTag);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to this, the component also uses computed properties to convert the "color", "fill", and "stroke" props to strings, which are used to generate class names for the icon. These class names are used to scope the CSS variables to the icon, so that they only affect the icon and not other elements on the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;computed: {
  computedColor() {
    return convertToStr(this.color);
  },
  computedFill() {
    return convertToStr(this.fill);
  },
  computedStroke() {
    return convertToStr(this.stroke);
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;convertToStr&lt;/code&gt; function inside the computed convert the multiple color type input to common standard and that color is used to apply in the icon.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function convertToStr(str) {
    if (!str) {
        return "";
    }
    if (str.startsWith("#")) {
        return str.substring(1);
    }
    if (str.startsWith("rgba")) {
        return str.substring(5, str.length - 1);
    }
    if (str.startsWith("rgb")) {
        return str.substring(4, str.length - 1);
    }
    if (str.startsWith("var")) {
        return str.substring(4, str.length - 1);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "watch" property is an important feature of the "vivid-icon" component, as it ensures that the icon's appearance is updated in real-time as the "color", "fill" and "stroke" props change. This provides a dynamic and interactive experience for the user, making it easy for them to see the changes they make to the icon's appearance.&lt;/p&gt;

&lt;p&gt;In addition to the "watch" property, the component also has a "beforeDestroy" hook that removes the component from the DOM and the component's style tag from the head of the document when the component is destroyed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;beforeDestroy() {
   this.styleTag.remove()
   this.$el.remove()
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that the component's resources are properly cleaned up when it is no longer needed, which is important for maintaining the performance of the application.&lt;/p&gt;

&lt;p&gt;To use the "vivid-icon" component in your Vue.js application, you simply need to import it and use it like any other Vue component. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
    &amp;lt;vivid-icon :color="color" :fill="fill" :stroke="stroke"&amp;gt; $vue&amp;lt;/vivid-icon &amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import vividIcon from '../components/vividIcon.vue'

export default {
    components: {
        vividIcon,
    },
    data() {
        return {
            color: 'red',
            fill: 'blue',
            stroke: 'green',
        }
    },
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the "vivid-icon" component is used with the "color", "fill" and "stroke" props set to "red", "blue", and "green" respectively. This would result in an icon that has a red color, blue fill, and green stroke.&lt;/p&gt;

&lt;p&gt;To implement the "vivid-icon" component in your Vue.js application, you will need to follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the SVG file that you want to use as an icon.&lt;/li&gt;
&lt;li&gt;Rename the file from .svg to .vue.&lt;/li&gt;
&lt;li&gt;This will allow you to use the file as a Vue component.&lt;/li&gt;
&lt;li&gt;Wrap the content of the SVG file with a  tag. This will ensure that the SVG content is properly rendered as an icon.&lt;/li&gt;
&lt;li&gt;Create an index file and add the component as shown in the example below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import vue from './vue';

export default {
  vue: {
    component: vue,
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Import that in vuetify plugin as shown in the example below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Vue from 'vue'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'
import IconValue  from './index.js'

Vue.use(Vuetify)

export default new Vuetify({
    icons: {
        iconfont: 'mdi', // default - only for display purposes
        values: IconValue,
    },
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now use the icon in your template by calling the component, passing in the props of size, fill, and stroke, and the class vivid-icon--color as shown in the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
    &amp;lt;vivid-icon size="45" fill="orange"&amp;gt;$vue&amp;lt;/vivid-icon&amp;gt;
&amp;lt;/template&amp;gt;
&amp;lt;script&amp;gt;
import VividIcon from '../components/vividIcon.vue'
export default {
    components: {
        VividIcon,
    },
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By following these steps, you will be able to easily use and customize icons in your Vue.js application using the "vivid-icon" component. The ability to import svg in vue+vuetify allows you to have a wide range of icons to choose from and customize as per your requirement. This component is easy to use, and it allows you to change the color, fill, and stroke of your icons and ensure that the changes are only applied to specific elements.&lt;/p&gt;

&lt;p&gt;In conclusion, the "vivid-icon" component is a powerful and flexible way to display and customize icons in a Vue.js application. With the ability to customize the color, fill, and stroke of the icon and the use of computed properties and the watch property, it provides a dynamic and interactive experience for the user. It is easy to use, and it is a great way to add a touch of visual appeal to your application.&lt;/p&gt;

&lt;p&gt;Source code: &lt;a href="https://github.com/vishnubhadri/vivid-icon-vue" rel="noopener noreferrer"&gt;vivid-icon-vue&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Vue + Vuetify : Custom Component Library</title>
      <dc:creator>Vishnuraj Sivakumar</dc:creator>
      <pubDate>Fri, 16 Jul 2021 08:27:46 +0000</pubDate>
      <link>https://dev.to/vishnubhadri/vue-vuetify-custom-component-library-2n9h</link>
      <guid>https://dev.to/vishnubhadri/vue-vuetify-custom-component-library-2n9h</guid>
      <description>&lt;p&gt;There is great support for &lt;a href="https://material.io/design/"&gt;Material Design&lt;/a&gt; in Vue.js. One of the libraries available for Vue.js is &lt;a href="https://vuetifyjs.com/"&gt;Vuetify&lt;/a&gt;. It is easy to incorporate into your Vue.js app and the result is appealing to the users’ eyes and most importantly Vuetify has plenty of components.&lt;/p&gt;

&lt;p&gt;But there are few cases that you want to common design or style and serve for multiple products. Vue has great support for creating App, Library, and Web components. You choose the type at the time of building. In this post, we are going to look at how to create a custom library using Vue.&lt;/p&gt;

&lt;p&gt;So here is my setup&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows 10 21H1
Node.js v12.22.1.
@vue/cli 4.5.13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start building the app, we have to install the Vue CLI. We do &lt;br&gt;
this by running:&lt;/p&gt;
&lt;h6&gt;
  
  
  if you don't have Vue CLI try this below step to run. if you already had Vue CLI skip this step
&lt;/h6&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @vue/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Once you install Vue CLI you start creating project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vue create --default custom-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after the command execute go to custom-lib and install Vuetify&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i --save --save-exact vuetify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  The reason we are using npm I instead of Vue add Vuetify is that when building as a library you need the dependencies inside the component
&lt;/h6&gt;

&lt;p&gt;and install the required dependencies to build.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i sass@~1.32 sass-loader@^10.1.1 deepmerge -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here your base setup is done.&lt;br&gt;
Next, you need to create custom components. I recommend creating components inside &lt;code&gt;src\components&lt;/code&gt;. I am creating a component name &lt;code&gt;customButton.vue&lt;/code&gt;. Find the code for &lt;code&gt;customButton.vue&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;v-btn color="orange"&amp;gt; I am custom button &amp;lt;/v-btn&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import { VBtn } from "vuetify/lib";
export default {
  name: "custom-button",
  components: { VBtn },
};
&amp;lt;/script&amp;gt;
&amp;lt;style lang="scss" scoped&amp;gt;
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  * templates are HTML that can be parsed by spec-compliant browsers and HTML parsers.
&lt;/h6&gt;

&lt;h6&gt;
  
  
  * script holds the logic of the component
&lt;/h6&gt;

&lt;h6&gt;
  
  
  * styles used style property of the component
&lt;/h6&gt;

&lt;p&gt;Note: The name inside the script is used to access the component.&lt;/p&gt;

&lt;p&gt;Once the component is created I recommended you create a &lt;code&gt;wrapper.js&lt;/code&gt; file inside a component. so that can control components that we may add or remove without deleting the &lt;code&gt;.vue&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;Here is my &lt;code&gt;wrapper.js&lt;/code&gt; code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export { default as customButton } from './customButton.vue'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  you can add as much as you want without affecting existing code
&lt;/h6&gt;

&lt;p&gt;Then create an &lt;code&gt;index.js&lt;/code&gt; in &lt;code&gt;src\index.js&lt;/code&gt;. We register all the components in &lt;code&gt;index.js&lt;/code&gt; that we do need to import every time in an application.&lt;br&gt;
Here is my &lt;code&gt;index.js&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as components from './components/wrapper';

const vueWrapper = {
    install(Vue) {
        componentRegistration(Vue);
    }
}

const componentRegistration = function (Vue) {
    for (let item in components) {
        Vue.component(components[item].name || "idx-test", components[item]);
    }
}


// Auto-install when vue is found (eg. in browser via &amp;lt;script&amp;gt; tag)
let GlobalVue = null;
if (typeof window !== 'undefined') {
    GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
    GlobalVue = global.Vue;
}
if (GlobalVue) {
    GlobalVue.use(vueWrapper);
}

export * from './components/wrapper';
export default vueWrapper;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  if you want to learn more try &lt;a href="https://vuejs.org/v2/guide/components-registration.html"&gt;Component Registration&lt;/a&gt;
&lt;/h6&gt;

&lt;p&gt;Hooray!. Our library is ready. All we need to do is build and test.&lt;br&gt;
After all this Setup your library files look like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6tpnU3Lz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0bom20vog8zrhqcd54j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6tpnU3Lz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0bom20vog8zrhqcd54j.png" alt="Library file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To build the project as the library you need to add some configuration in &lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;First, you need to run the script that &lt;a href="https://cli.vuejs.org/guide/build-targets.html#library"&gt;convert project as library&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, I am adding a script to build as the library&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
   "lib":"vue-cli-service build --target lib --inline-vue --name customLib ./src/index.js",
   "serve": "vue-cli-service serve"
 },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By Default, Vue builds lib for CommonJS and UMD. We just need to mention which file to take when we load in node/browser.&lt;br&gt;
We can do this by specifying main, module, unpack, and files in package.json.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"main": "dist/customLib.umd.js",
"module": "dist/customLib.esm.js",
"unpkg": "dist/customLib.min.js",
"files": [
  "dist/*"
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run &lt;code&gt;npm run lib&lt;/code&gt; and you will get files like the below one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; File                         Size                                                                Gzipped

  dist\customLib.umd.min.js    113.30 KiB                                                          39.58 KiB
  dist\customLib.umd.js        320.29 KiB                                                          87.29 KiB
  dist\customLib.common.js     319.90 KiB                                                          87.17 KiB
  dist\customLib.css           279.52 KiB                                                          32.71 KiB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So here you have created a library 🥳.&lt;/p&gt;

&lt;h6&gt;
  
  
  Tips: if you don't want seperate css file then you have to add
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  css: {
    extract: false
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 in &lt;code&gt;vue.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;and now it's time to check the library. For that, I am going to create a new project called application and use &lt;code&gt;npm link&lt;/code&gt;. you can also deploy and check from NPM. you can Learn more in &lt;a href="https://docs.npmjs.com/cli/v7/commands/npm-link"&gt;npm link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First I am making the library a global package by using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then Go to the application and add map lib to the application using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm link custom-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and install the library as a dependency by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i ../custom-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  if you clone this project just run &lt;code&gt;npm run link&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;After all the above steps are done navigate to &lt;code&gt;main.js&lt;/code&gt; in the application and import and use the library by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import library from 'custom-lib'
import 'custom-lib/dist/customLib.css'
Vue.use(library);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then go to &lt;code&gt;App.vue&lt;/code&gt; and call the component we created in a template like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
 &amp;lt;custom-button&amp;gt;&amp;lt;/custom-button&amp;gt;
&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and run. you will get output in &lt;code&gt;http://localhost:8080/&lt;/code&gt; and it looks like &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--edyPDnIe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8arho8m2gjtn3tdmjgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--edyPDnIe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8arho8m2gjtn3tdmjgt.png" alt="Application output"&gt;&lt;/a&gt;&lt;br&gt;
That's all.&lt;/p&gt;

&lt;h6&gt;
  
  
  if you face error in eslint. try to remove &lt;code&gt;"eslint:recommended"&lt;/code&gt; from &lt;code&gt;package.json&lt;/code&gt;, run &lt;code&gt;npm i&lt;/code&gt;and try again.
&lt;/h6&gt;

&lt;p&gt;Find the source code at&lt;br&gt;
&lt;a href="https://github.com/vishnubhadri/vue-vuetify-library"&gt;github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>vuetify</category>
    </item>
  </channel>
</rss>
