Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vuetify icon not showing

I am using vue.js and vuetify. I want to add an icon but it is not working as expected (not rendered).

How can I fix this?

Please refer to the following code:

main.js

import Vue from 'vue' import Vuetify from "vuetify"; import "vuetify/dist/vuetify.min.css";  Vue.use(Vuetify); 

index.html

<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet"> 

calendar.vue

<i class="material-icons"> keyboard_arrow_down </i> 

I want it to look like an icon, not code.

enter image description here

like image 870
eunhee ju Avatar asked Jul 16 '19 09:07

eunhee ju


People also ask

What icons does Vuetify use?

Vuetify comes bootstrapped with support for Material Design Icons, Material Icons, Font Awesome 4 and Font Awesome 5. By default, applications will default to use Material Design Icons .

Does Vuetify support Vue 3?

The current version of Vuetify does not support Vue 3. Support for Vue 3 will come with the release of Vuetify v3 . When creating a new project, please ensure you selected Vue 2 from the Vue CLI prompts, or that you are installing to an existing Vue 2 project.


2 Answers

With Vue CLI 3 we have no index.html in the src folder so alternatively you can

npm install --save material-design-icons-iconfont 

and import it in the main.js file

import 'material-design-icons-iconfont/dist/material-design-icons.css' 
like image 50
Hasnat Safder Avatar answered Sep 24 '22 14:09

Hasnat Safder


Had this issue with Vuetify 2.1.3 installed via the vuetify-loader 1.2.2

Seems like previous solutions do not work becues the default icons library has changed to mdi-font.

Solution was:

yarn add @mdi/font 

And in the file main.js (or plugins/vueitfy.js if exists) add this line below the imports

import '@mdi/font/css/materialdesignicons.css' 
like image 21
BenB Avatar answered Sep 25 '22 14:09

BenB