Giter VIP home page Giter VIP logo

vue-mdi-svg's Introduction

Material Design Svg Icons for Vue.js

Library to render Material Design Svg Icons in Vue.js

๐Ÿ“– Doc for Simplified Chinese

Setup

Here we use @mdi/js as an example

yarn add @mdi/js @yeliulee/vue-mdi-svg
# OR
npm install @mdi/js @yeliulee/vue-mdi-svg

Example

For better Tree Shaking Optimization, you have to import icons by your self

If you want to import all icons to your apps, please refer to mdi-vue

(Recommended to build your Vue.js App with Vite)

For Vue 2

// main.[js|ts] According to your project
import Vue from 'vue';
import "@yeliulee/vue-mdi-svg/src/styles.css" // styles of  icon component
import MdiSvg from "@yeliulee/vue-mdi-svg/v2"
import App from './App.vue';

Vue.use(MdiSvg);


// demo.vue
<template>
  <div>
    <MdiSvg> {{ mdiAccount }} </MdiSvg>
  </div>
</template>

<script>
import { mdiAccount } from "@mdi/js"
export default {
  data: () => ({
    mdiAccount
  })
}
</script>

For Vue 3

// main.[js|ts] According to your project
import { createApp } from 'vue'
import "@yeliulee/vue-mdi-svg/src/styles.css"
import MdiSvg from "@yeliulee/vue-mdi-svg/v3" // or just "@yeliulee/vue-mdi-svg"
import App from './App.vue' // According to your code

const app = createApp(App)
app.use(MdiSvg)
// etc...


// demo.vue [same as vue2 without setup syntax]
<template>
  <div>
    <MdiSvg>{{ mdiWechat }} </MdiSvg>
  </div>
</template>

<script setup lang="ts">
import { mdiWechat } from '@mdi/js'
</script>

Nuxt.js 2 / 3

both Nuxt.js 2 / 3 support Vue plugins, please read the corresponding documentation

Props

path(optional)

The path of Svg, it won't work if slot is used

<template>
  <div>
    <MdiSvg :path="mdiReact" />
  </div>
</template>

<script setup lang="ts">
import { mdiReact } from '@mdi/js'
</script>

title

The description of svg.

size(numeric or string; default: 24)

The width and height of the icon, it will work if no width or height is provided

<MdiSvg :size="48"> {{ your icon }} </MdiSvg>

<MdiSvg :width="16" :height="16"> {{ your icon }} </MdiSvg>

width

The width of the icon

height

The height of the icon

viewBox

The viewbox of the svg icon

<MdiSvg :viewBox="'0 0 24 24'"> {{ your icon }} </MdiSvg>

spin

Apply a spin/rotate animation to the icon

<MdiSvg spin> {{ your icon }} </MdiSvg>
<MdiSvg :spin="true"> {{ your icon }} </MdiSvg>

Credits

This libray is based on mdi-vue, thanks to @therufa and all mdi-vue's contributors

vue-mdi-svg's People

Contributors

yeliulee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

csa-f

vue-mdi-svg's Issues

Add documentation for viewBox

Thanks for the library! I use it with great satisfaction under Vue3.
Could you add documentation for :viewBox? I discovered by trial and error that I have to use :viewBox="'0,0,24,24'" that is, a string.
Thanks!
mario

No more able to shift position of the icon

The component is really useful. Thanks!
But after a recent update I'm not able anymore to move slightly the icon position.
In my application I have, for example, the following to put a star before the title and adjusting its position to better align with the text:

<div>
            <MdiSvg  :size="18" :path="mdiStar" class="starred" />
            <span>The title</span>
</div>

.starred {
    color: yellow;
    transform: translate(-3px, 8px);
}

But now the transform: translate(-3px, 8px); is totally ignored. What changed?

Or is it the right thing to do to use position: relative to position the icon?

Thanks for your help!
mario

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.