Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use animated material icons in vuetify

By the v-icon component of Vuetify, using mainstream material design icons is quite straightforward like:

<v-icon>home</v-icon>

Now, I wonder if animated material icons are supported and can be used in Vuetify in a similar fashion -I mean without having to add extra lines of css code etc. if possible.

In the examples, I have noticed the usage of fa-spin for Font Awesome; yet it is out of scope. I am bound to Google's material icons library.

EDIT: The specific kind of behavior I need is in the video examples in transitions section here: https://material.io/design/iconography/animated-icons.html# [See how a play button becomes pause with a smooth animation when clicked].

like image 356
vahdet Avatar asked Aug 29 '18 19:08

vahdet


People also ask

How do I use material icons in Vuetify?

The v-icon component provides a large set of glyphs to provide context to various aspects of your application. For a list of all available icons, visit the official Material Design Icons page. To use any of these icons simply use the mdi- prefix followed by the icon name.

How do I add material design icons in Vuetify?

Material Design Icons - JS SVGUse the SVG paths as designated in @mdi/js . This is the recommended installation when optimizing your application for production. You ONLY need to include this if you plan on using more than the default icons.

How do I import icons into Vue?

In the generated source, first change main. js to this: import { createApp } from "vue"; import App from "./App. vue"; import { library } from "@fortawesome/fontawesome-svg-core"; import { faPhone } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; library.

How do I change the color of my Vuetify icon?

By default, Vuetify sets the color of icons using a 2 × class specificity (i.e: . theme--light. v-icon ), so we need to use something slightly higher i.v-icon. v-icon ( 1 × el + 2 × class ).


1 Answers

I found this page when I wanted to mimic the animation of the chevron icon when toggling the expansion panels within a v-menu icon. I am not sure if this is exactly what you needed, but this is how I've done it:

<template>
  <v-menu offset-y v-model="menuValue">
    <template v-slot:activator="{ on }">
      <v-btn v-on="on" :class="{active: menuValue}">
        <v-icon>mdi-chevron-down</v-icon>
      </v-btn>
    </template>
  </v-menu>
</template>

<script>
  export default {
    data() {
      return {
        menuValue: null
      };
    }
  };
</script>

<style lang="scss" scoped>
  .v-btn.active .v-icon {
    transform: rotate(-180deg);
  }
</style>
like image 96
kelvin Avatar answered Oct 05 '22 11:10

kelvin