Categories
Top Vue Packages

Top Vue Packages for Adding Tables, Checkboxes, and Manipulating Text

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding tables, checkboxes, and manipulating text.

Vuetable-2

Vuetable-2 is an easy to use table component that can get data directly from an API and display it.

It’s made for Vue apps.

To use it, we run:

npm i vuetable-2

to install it.

Then we can write:

<template>
  <div>
    <vuetable
      ref="vuetable"
      api-url="https://vuetable.ratiw.net/api/users"
      :fields="['name', 'nickname', 'salary']"
    ></vuetable>
  </div>
</template>

<script>
import Vuetable from "vuetable-2/src/components/Vuetable";

export default {
  components: {
    Vuetable
  }
};
</script>

to use it.

api-url is the URL with the data.

fields is the fields to display.

The items are within the data property of the returned JSON.

fields pick the fields of the entries to display.

vue-table-component

vue-table-component is another handy table component for Vue apps.

To use it, we run:

npm i vue-table-component moment

to install and moment, which is a dependency of this package.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import { TableComponent, TableColumn } from "vue-table-component";

Vue.component("table-component", TableComponent);
Vue.component("table-column", TableColumn);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <table-component :data="data" sort-by="songs" sort-order="asc">
      <table-column show="firstName" label="First name"></table-column>
      <table-column show="lastName" label="Last name"></table-column>
    </table-component>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [
        {
          firstName: "james",
          lastName: "smith"
        },
        {
          firstName: "alex",
          lastName: "wong"
        }
      ]
    };
  }
};
</script>

We use the built in components to create the table.

table-component lets us populate the data.

table-column display the entries.

Now we have a table with sorting and filtering.

show is the property name of the entry to show.

label is the heading for the column.

vue-nl2br

vue-nl2br turns new line characters to br elements.

To use it, we run:

npm i vue-nl2br

to install it.

Then we write:

<template>
  <nl2br tag="p" :text="`foonbar`"/>
</template>

<script>
import Nl2br from "vue-nl2br";

export default {
  components: {
    Nl2br
  }
};
</script>

to use the nl2br component.

tag is the tag of the element to render.

text is the text that we want to display.

pretty-checkbox-vue

pretty-checkbox-vue is a package that lets us add a nice looking checkbox into our Vue app.

To use it, we run:

npm i pretty-checkbox-vue

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import PrettyCheckbox from "pretty-checkbox-vue";

Vue.use(PrettyCheckbox);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <p-check name="check" color="success" v-model="check">check</p-check>
  </div>
</template>

<script>
export default {
 data(){
   return {
     check: false
   }
 }
};
</script>

We use the p-check component to add the checkbox.

v-model binds the checked value to the checkbox.

We can style the checkbox and set hover and toggle states and more.

vue-clamp

vue-clamp is a clamp component to truncate text.

To use it, we run:

npm i vue-clamp

Then we can use it by writing:

<template>
  <v-clamp autoresize :max-lines="1">{{ text }}</v-clamp>
</template>

<script>
import VClamp from "vue-clamp";

export default {
  components: {
    VClamp
  },
  data() {
    return {
      text:
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mollis lorem in facilisis lacinia. Fusce tempor nisl non tempor sagittis. Mauris tempor massa sit amet urna dignissim, id scelerisque leo eleifend. Integer consectetur orci nisl, sit amet lobortis risus ultricies et. Suspendisse semper condimentum libero, vitae aliquet nisi rhoncus a. Nulla consectetur tincidunt auctor. Praesent consequat nisl eget eros fermentum auctor. Sed pretium augue at sapien maximus eleifend. In in aliquam felis, vitae mollis nunc. Sed id tellus justo. Nam justo turpis, ultrices ut sagittis ac, accumsan vel augue. Maecenas pulvinar ultricies ipsum sed consectetur. Donec congue nulla eget sapien tempus, vitae placerat urna imperdiet. Pellentesque justo nisl, ultricies vel dignissim nec, finibus ornare dolor."
    };
  }
};
</script>

We import the component and set the max-line prop to set the maximum number of lines to display.

autoresize makes the clamped text resize automatically.

Conclusion

vue-clamp is a component to truncate text.

vue-nl2br lets us convert line breaks to br elements.

Vuetable-2 and vue-table-component are table components.

pretty-checkbox-vue is an easy to use checkbox.

Categories
Top Vue Packages

Top Vue Packages for Adding Text Editors, Animated Numbers, and Tag Input

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at how the best packages for adding text editors, animated numbers, and tag input.

@ckeditor/ckeditor5-vue

This package is the Vue version of CKEditor.

We can install it by running:

npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import CKEditor from "@ckeditor/ckeditor5-vue";

Vue.use(CKEditor);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div id="app">
    <ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
  </div>
</template>

<script>
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";

export default {
  name: "app",
  data() {
    return {
      editor: ClassicEditor,
      editorData: "<p>Content of the editor.</p>",
      editorConfig: {}
    };
  }
};
</script>

The ckeditor component binds to the editorData , which contains HTML content.

By default, the editor has buttons for bold, italic, formatting, links, images, and lists.

We can add plugins as we wish.

This can be done bu building from source.

@braid/vue-formulate

@braid/vue-formulate is a package that lets us add form elements and validation to a form.

To install it, we run:

npm install @braid/vue-formulate

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueFormulate from "@braid/vue-formulate";

Vue.use(VueFormulate);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div id="app">
    <FormulateInput type="text" v-model="name"/>
    <p>{{name}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      name: ""
    };
  }
};
</script>

We add an input by using the FormulateInput component.

v-model binds to the name state.

The type can be any type that a regular form input element takes like text and email .

We can add validation by writing:

<template>
  <div id="app">
    <FormulateInput type="email" v-model="email" validation="required|email"/>
    <p>{{email}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      email: ""
    };
  }
};
</script>

We just add the validation prop with the rules we want to include.

Now we see validation messages when we didn’t type in an email.

It also supports binding a model to multiple inputs.

We can have multiple inputs that bind to one value.

For example, we can write:

<template>
  <div id="app">
    <FormulateInput
      type="text"
      label="favorite fruit"
      validation="not:apple"
      validation-name="favorite fruit"
      error-behavior="live"
      v-model="fruit"
    />
    <FormulateInput
      type="radio"
      v-model="fruit"
      error-behavior="live"
      validation="in:apple,orange"
      :options="{ apple: 'Apple', orange: 'Orange' }"
    />
    <p>{{fruit}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      fruit: ""
    };
  }
};
</script>

There are many things that we can do with VueFormulate for building forms.

animated-number-vue

animated-number-vue is a Vue plugin that lets us add an animated number to a Vue app.

To use it, we install it by writing:

npm i animated-number-vue

Then we can use it by writing:

<template>
  <animated-number :value="price" :formatValue="formatToPrice" :duration="600"/>
</template>
<script>
import AnimatedNumber from "animated-number-vue";

export default {
  components: {
    AnimatedNumber
  },
  data() {
    return {
      price: 1000
    };
  },
  methods: {
    formatToPrice(value) {
      return `$${value.toFixed(2)}`;
    }
  }
};
</script>

We add the animated-number component to display the number by animating it into the screen.

The formatValue prop lets us format the number the way we like.

The duration is the length of the animation.

It also takes the updare ,run , begin , and complete props, which are all function valued.

They’re run during those phases of the animation.

@frk/vue-tags-input

@frk/vue-tags-input is an input component for letting us add tags.

To install it, we run:

npm i @frk/vue-tags-input

Then we can use it by writing:

<template>
  <div>
    <vue-tags-input v-model="value" :tags="tags" @tags-changed="newTags => tags = newTags"/>
    <p>{{tags}}</p>
  </div>
</template>

<script>
import VueTagsInput from "@frk/vue-tags-input";

export default {
  components: {
    VueTagsInput
  },
  data() {
    return {
      value: "",
      tags: []
    };
  }
};
</script>

We have the vue-tags-input component from the package.

v-model binds to the tag being entered.

tags has the tags entered.

The tags event is emitted, and we can use that to assign the entered tags to the value.

Conclusion

@ckeditor/ckeditor5-vue lets us add a rich text editor that’s customizable.

animated-number-vue lets us create a number display that are animated.

@frk/vue-tags-input is a useful tags input.

Categories
Top Vue Packages

Top Vue Packages for Truncating Text, and Display Dialogs and Modals

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding dialog boxes, select items from a tree, and display truncated text.

vue-thin-modal

vue-thin-modal is a simple modal component that we can use in our Vue app.

To use it, we run:

npm i vue-thin-modal

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueThinModal from "vue-thin-modal";
import "vue-thin-modal/dist/vue-thin-modal.css";

Vue.use(VueThinModal);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <button type="button" [@click](http://twitter.com/click "Twitter profile for @click")="open">Open Modal</button>
    <modal name="hello">
      <div class="basic-modal">
        <h1 class="title">hello</h1>
        <button class="button" type="button" @click="close">Close Modal</button>
      </div>
    </modal>
  </div>
</template>

<script>
export default {
  methods: {
    open() {
      this.$modal.push("hello");
    },

    close() {
      this.$modal.pop();
    }
  }
};
</script>

We import the component and its CSS.

Then we display the modal with the modal component.

The content is in between the tags.

We call this.$modal.push to display it. The argument is the value of the name prop of the modal.

And we call this.$modal.pop to close it.

vue-clamp

vue-clamp is a simple directive for truncating text.

To use it, we run:

npm i vue-clamp

to install it.

Then we write:

<template>
  <v-clamp autoresize :max-lines="1">{{ text }}</v-clamp>
</template>

<script>
import VClamp from "vue-clamp";

export default {
  components: {
    VClamp
  },
  data() {
    return {
      text: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nibh neque, dignissim sit amet libero at, aliquet tempus urna. Aenean luctus accumsan feugiat. Nunc dui purus, imperdiet eu suscipit et, convallis vehicula nulla. Quisque nec nisi elementum, tincidunt est eu, sollicitudin enim. Sed fermentum massa urna, at malesuada leo egestas vitae. Aenean vulputate sem libero, nec sagittis arcu varius et. Donec et felis augue. Nunc euismod gravida nibh, id volutpat mauris placerat nec. Integer sit amet purus non ligula ullamcorper tempor in at massa. Donec pellentesque convallis pharetra.`
    };
  }
};
</script>

to truncate our text.

We use the v-clamp component with the autoresize prop to make it resize automatically.

max-line sets the max number of lines to display.

vue-tree-halower

vue-tree-halower is an input component where we can choose the value from a tree structure.

To use it, we can run:

npm i vue-tree-halower

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import { VTree, VSelectTree } from "vue-tree-halower";
import "vue-tree-halower/dist/halower-tree.min.css";
Vue.use(VTree);
Vue.use(VSelectTree);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <v-select-tree :data="treeData" v-model="selected"/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      treeData: [
        {
          title: "fruit",
          expanded: true,
          children: [
            {
              title: "apple",
              expanded: true,
              children: [
                {
                  title: "mcintosh"
                },
                {
                  title: "golden delicious"
                }
              ]
            },
            {
              title: "drink",
              children: [
                {
                  title: "<span style='color: red'>beer</span>"
                },
                {
                  title: "<span style='color: green'>wine</span>"
                }
              ]
            }
          ]
        }
      ],
      selected: []
    };
  }
};
</script>

We use the v-select-item component to add the component.

Then we set the data prop to tree data to populate the choices.

title is shown as the name of the node.

children are children of the node.

expanded indicates that the tree node is expanded if it’s true.

v-model binds to the select choices.

It includes many other choices or customizations.

Vuejs Dialog Plugin

Vuejs Dialog Plugin is a plugin that provides us with a promised based dialog box.

To use it, we run:

npm i vuejs-dialog

Then we use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VuejsDialog from "vuejs-dialog";
import "vuejs-dialog/dist/vuejs-dialog.min.css";
Vue.use(VuejsDialog);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div></div>
</template>

<script>
export default {
  async mounted() {
    const dialog = this.$dialog.alert("alert");
    console.log("closed");
  }
};
</script>

We import the plugin and styles.

Then we can call this.$dialog.alert to display the dialog.

Conclusion

vue-thin-modal lets us add a simple modal to our Vue app.

vue-clamp is a component that lets us display truncated text.

vue-tree-halower is a select input that lets us select items from a tree.

Vuejs Dialog Plugin is a promise based dialog plugin.

Categories
Top Vue Packages

Top Vue Packages for Displaying Messages, Lazy Loading Images, and Modals

asy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for displaying messages, lazy loading images, and adding modals.

vue-toastr

vue-toastr is a toast component for Vue apps.

To use it, we run:

npm i vue-toastr

to install it.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueToastr from "vue-toastr";
Vue.use(VueToastr, {});

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div></div>
</template>

<script>
export default {
  mounted() {
    this.$toastr.defaultPosition = "toast-top-left";
    this.$toastr.s("<b>hello</b>");
  }
};
</script>

We create a toast by registering a plugin.

Then we use the $toastr property to set the default position and display the toast with the s method.

HTML is supported.

Other options like timeout, styles, etc. can be set.

vue-thin-modal

If we want to add models to our app easily, we can use the vue-thin-modal package to do it.

To install it, we run:

npm i vue-thin-modal

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueThinModal from "vue-thin-modal";
import "vue-thin-modal/dist/vue-thin-modal.css";

Vue.use(VueThinModal);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <button type="button" @click="open">Open Modal</button>
    <modal name="demo">
      <div class="basic-modal">
        <h1 class="title">Title</h1>
        <button class="button" type="button" @click="close">Close Modal</button>
      </div>
    </modal>
  </div>
</template>

<script>
export default {
  methods: {
    open() {
      this.$modal.push("demo");
    },

    close() {
      this.$modal.pop();
    }
  }
};
</script>

We register the component and import the CSS.

Then we use the modal component to add the modal.

this.$modal.push opens the modal.

The argument is the value of the name prop of modal .

To close it, we call the pop method.

v-lazy-image

v-lazy-image is an image component that loads the image only when it’s shown on the screen.

To use it, we run:

npm i v-lazy-image

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import { VLazyImagePlugin } from "v-lazy-image";

Vue.use(VLazyImagePlugin);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <v-lazy-image
      src="http://placekitten.com/200/200"
      src-placeholder="http://placekitten.com/201/201"
    />
  </div>
</template>

<script>
export default {};
</script>

to use it.

src is the URL of the actual image.

src-placeholder is the URL of the placeholder image.

We can progressively load images.

To do that, we can add transitions effects with CSS.

For instance, we can write:

<template>
  <div>
    <v-lazy-image
      src="http://placekitten.com/200/200"
      src-placeholder="http://placekitten.com/201/201"
    />
  </div>
</template>

<script>
export default {};
</script>

<style scoped>
.v-lazy-image {
  filter: blur(20px);
  transition: filter 0.7s;
}
.v-lazy-image-loaded {
  filter: blur(0);
}
</style>

We just add transition effects to the v-lazy-image class to add a transition effect when the image loads.

Responsive images are also supported.

vue-flash-message

vue-flash-message is a package that lets us show messages on the screen.

To install it, we run:

npm i vue-flash-message

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueFlashMessage from "vue-flash-message";
Vue.use(VueFlashMessage);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <flash-message></flash-message>
  </div>
</template>

<script>
export default {
  mounted() {
    this.flash("loaded", "success");
  }
};
</script>

We use the flash-message component to display messages which will be displayed for a few seconds.

We call this.flash to show the message.

The first argument is the content.

The 2nd argument is the type.

We can add the CSS that comes with the package to add styles:

import Vue from "vue";
import App from "./App.vue";
import VueFlashMessage from "vue-flash-message";
import "vue-flash-message/dist/vue-flash-message.min.css";

Vue.use(VueFlashMessage);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

Other kinds of messages include error, warning, and info.

Conclusion

We can use vue-toastr or vue-flash-messag to display messages.

vue-thin-modal is a modal component for Vue apps.

v-lazy-image is a component for lazy loading images.

Categories
Top Vue Packages

Top Vue Packages for Adding Sliders, Highlighting Code, and More

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding auto-scrolling, animating numbers, highlighting code, sliders, and displaying notifications.

vue-seamless-scroll

vue-seamless-scroll lets us add a component that automatically scrolls through its contents.

To use it, we run:

npm i vue-seamless-scroll

to install it.

Then we can write:

<template>
  <vue-seamless-scroll :data="listData" class="seamless-warp">
    <ul class="item">
      <li v-for="item in listData" :key="item">
        <span v-text="item"></span>
      </li>
    </ul>
  </vue-seamless-scroll>
</template>

<script>
import vueSeamlessScroll from "vue-seamless-scroll";

export default {
  components: {
    vueSeamlessScroll
  },
  data() {
    return {
      listData: Array(20)
        .fill()
        .map((_, i) => i)
    };
  }
};
</script>

We register the component.

And then we use the vue-seamless-scroll component.

We set the data prop to set the scroll data.

Then we loop through the entries we want to render.

Whatever is inside will be scrolled through continuously.

It’ll loop so it’ll keep scrolling from beginning to end until we navigate away from the page.

animated-number-vue

animated-number-vue lets us animate numbers in a Vue app.

To use it, we run:

npm i animated-number-vue

to install it.

Then we use it by writing:

<template>
  <animated-number :value="value" :formatValue="formatToPrice" :duration="300"/>
</template>
<script>
import AnimatedNumber from "animated-number-vue";

export default {
  components: {
    AnimatedNumber
  },
  data() {
    return {
      value: 1000
    };
  },
  methods: {
    formatToPrice(value) {
      return `$ ${value.toFixed(2)}`;
    }
  }
};
</script>

We use the animated-number component to display the animated number.

duration is the length of the animation.

value is the end number of the animation.

Vue Carousel 3d

Vue Carousel 3d is a 3D carousel for Vue apps.

To use it, we run:

npm i vue-carousel-3d

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import Carousel3d from "vue-carousel-3d";

Vue.use(Carousel3d);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <carousel-3d>
      <slide :index="0">Slide 1</slide>
      <slide :index="1">Slide 2</slide>
      <slide :index="2">Slide 3</slide>
    </carousel-3d>
  </div>
</template>

<script>
export default {};

to use it.

We use the carousel-3d with at least 3 slides.

The slide components house the slides.

Then we can flip through the slides.

Vue Toast Notification

Vue Toast Notification is a Vue plugin that lets us display toast in our Vue app.

To use it, we install it by running:

npm i vue-toast-notification

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueToast from "vue-toast-notification";
import "vue-toast-notification/dist/theme-default.css";

Vue.use(VueToast);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div id="app"></div>
</template>

<script>
export default {
  mounted() {
    this.$toast.open("hello!");
  }
};
</script>

We import the CSS and register the library.

Then we call this.$toast.open to open a basic notification.

We also display notifications for errors, warnings, and info messages.

Also, we can write:

<template>
  <div id="app"></div>
</template>

<script>
export default {
  mounted() {
    this.$toast.open({
      message: "Hello Vue",
      type: "success",
      duration: 5000,
      dismissible: true
    });
  }
};
</script>

to set our own options.

dismissible makes it dismissible.

message is the message.

type is the type of toast.

duration is the length of time to display the toast.

vue-hljs

vue-hljs lets us display code in our Vue app with syntax highlighting.

To use it, we run:

npm i vue-hljs

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import vueHljs from "vue-hljs";
import "vue-hljs/dist/vue-hljs.min.css";

Vue.use(vueHljs);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div id="app">
    <div v-highlight>
      <pre>
        <code class="javascript">const foo = 'bar'</code>
      </pre>
    </div>
  </div>
</template>

<script>
export default {};
</script>

to display the code.

We just use the v-highlight directive to add the syntax highlighting.

Conclusion

vue-hljs lets us add syntax highlighting to our code display.

vue-seamless-scroll makes scrolling automatic.

Vue Toast Notification displays notifications in various formats.

Vue Carousel 3d lets us add a 3D slider.

animated-number-vue animates numbers.