npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dbetka/vue-material-symbols

v1.2.0

Published

Vue3 Material Design Symbols

Downloads

86

Readme

vue-material-symbols

Vue3 material design symbols fully typed component. Works well with TypeScript and JavaScript. Provides easy customization by CSS classes. Fonts based on https://fonts.google.com/icons.

npm version License: MIT

Demo

Open demo

How to start

Installation

npm install @dbetka/vue-material-symbols

Setup in a project with default configuration

Add as Vue3 plugin:

import materialSymbolsPlugin from '@dbetka/vue-material-symbols';
import 'material-symbols/index.css';

const app = createApp(App);
app.use(materialSymbolsPlugin);
// defaultType: 'outlined',
// defaultWeight: '300',
// defaultGrade:  'medium',
// defaultSize: 24,
// defaultFilled: false,

Setup in project with configuration

import materialSymbolsPlugin from '@dbetka/vue-material-symbols';
import 'material-symbols/index.css';

const app = createApp(App);
app.use(materialSymbolsPlugin, {
  defaultWeight: '100',
  defaultGrade: 'thin',
  defaultSize: 24,
  defaultType: 'outlined',
  defaultFilled: false,
});

Setup in project with responsive size

import materialSymbolsPlugin from '@dbetka/vue-material-symbols';
import 'material-symbols/index.css';

const app = createApp(App);
app.use(materialSymbolsPlugin, {
  defaultSize: '1.5em',
});

Usage

Base examples

<script setup>
  import { MaterialSymbol } from '@dbetka/vue-material-symbols';
</script>
<template>
  <div>
    <MaterialSymbol name="delete" />
    <MaterialSymbol name="delete" filled />
    <MaterialSymbol name="delete" type="outlined" />
    <MaterialSymbol name="delete" type="rounded" />
    <MaterialSymbol name="delete" type="sharp" />
    <MaterialSymbol name="delete" size="26" />
  </div>
</template>

Usage in Composition API

<script setup lang="ts">
  import { MaterialSymbol, SymbolsProp } from '@dbetka/vue-material-symbols';
  import { computed } from 'vue';

  const props = defineProps({
    done: Boolean,
  });

  const symbolName = computed<SymbolsProp>(() => props.done ? 'done' : 'hourglass_empty')
</script>
<template>
  <div>
    <MaterialSymbol :name="symbolName" />
  </div>
</template>

Or without TypeScript:

<script setup>
  import { useSymbols, MaterialSymbol } from '@dbetka/vue-material-symbols';
  import { computed } from 'vue';

  const props = defineProps({
    done: Boolean,
  });

  const symbols = useSymbols()
  const symbolName = computed(() => props.done ? symbols.names.done : symbols.names.hourglass_empty)
</script>
<template>
  <div>
    <MaterialSymbol :name="symbolName" />
  </div>
</template>

Own styles

Set icon color

Component with CSS example:

<script setup>
  import { MaterialSymbol } from '@dbetka/vue-material-symbols';
</script>
<template>
  <div>
    <MaterialSymbol name="delete" class="red"/>
  </div>
</template>

<style>
.red {
   color: red;
}
</style>

Symbols metadata

Access to symbols metadata:

<script setup lang="ts">
  import { metadata } from '@dbetka/vue-material-symbols/dist/metadata';
  import { computed } from 'vue';
  
  /*** SymbolMetadata
    name: string
    version: number
    popularity: number
    codepoint: number
    categories: string[]
    tags: string[]
   */
  
  const symbolsSortedByPopularity = computed(() => metadata.sort((a, b) => b.popularity - a.popularity))
</script>
<template>
  <div>
    <MaterialSymbol v-for="symbol of symbolsSortedByPopularity" :key="symbol.name" :name="symbol.name" />
  </div>
</template>