Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support for Material Symbols #20053

Open
bun-lau opened this issue Jun 24, 2024 · 3 comments · May be fixed by #20798
Open

[Feature Request] Support for Material Symbols #20053

bun-lau opened this issue Jun 24, 2024 · 3 comments · May be fixed by #20798
Labels
C: VIcon VIcon E: icons Icons composable Service: Icons T: feature A new feature upstream Problem with a third party library that we may have to work around

Comments

@bun-lau
Copy link

bun-lau commented Jun 24, 2024

Problem to solve

the new Material Icons collection is now "Material Symbols"

Proposed solution

adding Material Symbols option/differentiate by icon name
updating the class name

@VIXI0
Copy link

VIXI0 commented Dec 1, 2024

i need this

@MatthewAry MatthewAry added upstream Problem with a third party library that we may have to work around C: VIcon VIcon Service: Icons E: icons Icons composable T: feature A new feature labels Dec 3, 2024
@github-actions github-actions bot removed the S: triage label Dec 3, 2024
@J-Sek
Copy link
Contributor

J-Sek commented Dec 23, 2024

Initially it looked like a good idea, until I actually integrated them and noticed that

  • most of the icons have 6 variants "regular", "rounded", "sharp", "outline, "outline-rounded, "outline-sharp" - meaning the set is bloated, harder to lookup
  • depending on the distribution they may be forced into distinct sets
  • some symbols may be missing... it honestly feels like a beta release at the moment

You can actually use them today as aliases from "MD" set seem to work just fine.

import '@material-symbols/font-400/outlined.css'
import { aliases } from 'vuetify/iconsets/md' // aliases are the same
import { VLigatureIcon } from 'vuetify/lib/composables/icons.mjs'
import { h } from 'vue'
const mat = { component: (props: any) => h(VLigatureIcon, { ...props, class: 'material-symbols-outlined' }) }

import { createVuetify } from 'vuetify'

const vuetify = createVuetify({
  icons: {
    defaultSet: 'mat',
    aliases,
    sets: { mat },
  },
})
<v-container class="d-flex flex-wrap ga-3" width="600">
  <v-btn variant='outlined' v-for='ic in Object.values(aliases)' :key='ic' :icon='ic' />
</v-container>

image

Apart from incorrect symbols for $delimiter and $ratingFull it seems good enough.

But it does not feel like the font is ready for official Vuetify support. I can only recommend using it through nuxt-icons that loads used symbols from icones.js.org and has access to the full set (includes filled stars)

@J-Sek J-Sek linked a pull request Dec 23, 2024 that will close this issue
1 task
@VIXI0
Copy link

VIXI0 commented Dec 24, 2024

I was able to achieve this by creating an iconset and modify the render to accept a variant prop where i can specify: "regular", "rounded", "sharp", "outline", "outline-rounded, "outline-sharp" default to "outline" then render the icon based on classes.

IconSets allows you to modify vuetify icons

Remember to install material-symbols

USAGE

<v-icon icon="home_repair_service"></v-icon>
<v-icon variant="rounded" icon="home_repair_service"></v-icon>
<v-icon icon="mdi:mdi-menu-right"></v-icon>

here is the code if anyone need this:

import { h } from 'vue'
import type { IconSet, IconAliases, IconProps } from 'vuetify'
const aliases: IconAliases = {
  collapse: 'keyboard_arrow_up',
  complete: 'check',
  cancel: 'cancel',
  close: 'close',
  delete: 'cancel',
  // delete (e.g. v-chip close)
  clear: 'cancel',
  success: 'check_circle',
  info: 'info',
  warning: 'priority_high',
  error: 'warning',
  prev: 'chevron_left',
  next: 'chevron_right',
  checkboxOn: 'check_box',
  checkboxOff: 'check_box_outline_blank',
  checkboxIndeterminate: 'indeterminate_check_box',
  delimiter: 'fiber_manual_record',
  // for carousel
  sortAsc: 'arrow_upward',
  sortDesc: 'arrow_downward',
  expand: 'keyboard_arrow_down',
  menu: 'menu',
  subgroup: 'arrow_drop_down',
  dropdown: 'arrow_drop_down',
  radioOn: 'radio_button_checked',
  radioOff: 'radio_button_unchecked',
  edit: 'edit',
  ratingEmpty: 'star_border',
  ratingFull: 'star',
  ratingHalf: 'star_half',
  loading: 'cached',
  first: 'first_page',
  last: 'last_page',
  unfold: 'unfold_more',
  file: 'attach_file',
  plus: 'add',
  minus: 'remove',
  calendar: 'event',
  treeviewCollapse: 'arrow_drop_down',
  treeviewExpand: 'arrow_right',
  eyeDropper: 'colorize'
}

interface ExtendedIconProps extends IconProps {
  variant?: 'outlined' | 'sharp' | 'rounded'
}

const mds: IconSet = {
  component: (props: ExtendedIconProps) => {
    const iconClass = props.variant
      ? `material-symbols-${props.variant}`
      : 'material-symbols-outlined'
    return h(props.tag, {
      ...props,
      class: iconClass,
      innerHTML: props.icon
    })
  }
}

export { aliases, mds }

This is the Vuetify configuration using the icon set

import '@mdi/font/css/materialdesignicons.css'
import 'material-symbols'
import 'vuetify/styles'

import { aliases, mds } from './iconsets/mds'
import { mdi } from 'vuetify/iconsets/mdi'

import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import * as labsComponents from 'vuetify/labs/components'

export default createVuetify({
  components: {
    ...components,
    ...labsComponents,
  },
  directives,
  icons: {
    defaultSet: 'mds',
    aliases,
    sets: {
      mds,
      mdi
    },
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VIcon VIcon E: icons Icons composable Service: Icons T: feature A new feature upstream Problem with a third party library that we may have to work around
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants