How to add animation icon with button in Bootstrap VueJS?

Hi Friends đź‘‹,

Welcome To SortoutCode! ❤️

Add an animation icon with a button using BootstrapVue.We are using the b-button component for the button and icon we are using the b-icon component and for animation, I am going to use the animation props in BootstrapVue.

Today I am going to show you How you add an animation icon with a button using BootstrapVue in VueJS?

Table of contains

  • Setup the Vue.js
  • Install the Bootstrap and BootstrapVue
  • Create FirstComponent.vue and import it into App.js
  • Show the b-icon component
  • Add an icon with a button
  • Add an animation icon with a button

Let’s start today’s tutorial How do I add an animation icon with a button using BootstrapVue in VueJS?

Setup the Vue.js

First, we have to install the Vue project, I had installed the vueJS in my system. If you haven’t installed or have any problem with installation you can follow this article, which will show you step by step process of installation.

How to Install the VueJS project?

Install the Bootstrap and BootstrapVue

First, we have to install the Vue project, I had installed the vueJS in my system. If you haven’t installed or have any problem with installation you can follow this article, which will show you step by step process of installation. In that article, I had also show you how to install BootstrapVue in your vue.js project step by step.

How to install or configure vue-bootstrap in VueJS?

Create FirstComponent.vue and import it into App.js

Create the new component into src/components/ components folder.the component name is FirstComponent.vue and import into App.js file:

App.js

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

<script>
import FirstComponent from "./components/FirstComponent.vue";
export default {
  name: "App",
  components: {
    FirstComponent,
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Show the b-icon component

After vue-bootstrap installation and setup, I’m going to show you How to use the icon in BootstrapVue, as mentioned above here, I’m going to use the b-icon component on vue-bootstrap.

Let’s start today’s tutorial on how do you add bootstrap icons in BootstrapVue.

FirstComponent.vue

<template>
  <b-container>
    <b-row class="mt-5">
      <b-col>
        <b-icon icon="gear-fill"></b-icon>
        <b-icon icon="person-fill"></b-icon>
        <b-icon icon="inbox-fill"></b-icon>
      </b-col>
    </b-row>
  </b-container>
</template>

<script>

export default {
  name: "FirstComponent",
};
</script>

Output

bootstrap vue icon

Add icon with button

I’m going to add an icon with a button in BootstrapVue. Let’s see the code:

FirstComponent.vue

<template>
  <b-container>
    <b-row class="mt-5">
      <b-col>
        <b-button variant="outline-primary"><b-icon icon="gear-fill"></b-icon> Settings</b-button>
        <b-button variant="outline-primary"><b-icon icon="person-fill"></b-icon> Profile</b-button>
        <b-button variant="outline-primary"><b-icon icon="inbox-fill"></b-icon> Message</b-button>
      </b-col>
    </b-row>
  </b-container>
</template>

<script>

export default {
  name: "FirstComponent",
};
</script>

Output

bootstrap vue icon with button

Add animation icon with button

I’m going to add animation with an icon with a button in BootstrapVue. For the animation we are using the animation props, Let’s see the code:

FirstComponent.vue

<template>
  <b-container>
    <b-row class="mt-5">
      <b-col>
        <b-button variant="outline-primary"><b-icon animation="spin" icon="gear-fill"></b-icon> Settings</b-button>
        <b-button variant="outline-primary"><b-icon icon="person-fill" animation="cylon"></b-icon> Profile</b-button>
        <b-button variant="outline-primary"><b-icon icon="inbox-fill" animation="fade"></b-icon> Message</b-button>
      </b-col>
    </b-row>
  </b-container>
</template>

<script>

export default {
  name: "FirstComponent",
};
</script>

Output

bootstrap vue animation icon with button

You can check the animation output on this link https://jsfiddle.net/wxeyu15g/

BootstrapVue animation icon with button

All the best đź‘Ť.

Follow me on Twitter