Skip to content

Commit 424a68f

Browse files
committed
feat(icons): support Material Symbols
1 parent 1d34a83 commit 424a68f

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

packages/docs/src/pages/en/features/icon-fonts.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,60 @@ export default createVuetify({
111111

112112
:::
113113

114+
### Material Symbols
115+
116+
New set of icons provided by Google. Provided as fonts with different weights or SVG. Comes with 3 distinct variants: 'Outlined', 'Rounded' and 'Sharp'.
117+
118+
#### Material Symbols - CSS/Font
119+
120+
```html
121+
<link href="https://cdn.jsdelivr.net/npm/@material-symbols/[email protected]/outlined.css" rel="stylesheet">
122+
```
123+
124+
Or as a local dependency:
125+
126+
::: tabs
127+
128+
```bash [pnpm]
129+
pnpm add @material-symbols/font-400 -D
130+
```
131+
132+
```bash [yarn]
133+
yarn add @material-symbols/font-400 -D
134+
```
135+
136+
``` bash [npm]
137+
npm install @material-symbols/font-400 -D
138+
```
139+
140+
```bash [bun]
141+
bun add @material-symbols/font-400 -D
142+
```
143+
144+
:::
145+
146+
```js { resource="src/plugins/vuetify.js" }
147+
import '@material-symbols/font-400/outlined.css' // Ensure you are using css-loader
148+
import { createVuetify } from 'vuetify'
149+
import { aliases, mat } from 'vuetify/iconsets/mat'
150+
151+
export default createVuetify({
152+
icons: {
153+
defaultSet: 'mat',
154+
aliases,
155+
sets: {
156+
mat: mat('outlined'),
157+
},
158+
},
159+
})
160+
```
161+
162+
::: error
163+
164+
This icon set is relatively new and does guarantee full overlap of symbols between variants. You may need to verify that symbols you need look correct or add custom icons to supplement the set you intend to use.
165+
166+
:::
167+
114168
#### MDI - JS SVG
115169

116170
This is the recommended installation when optimizing your application for production, as only icons used for Vuetify components internally will be imported into your application bundle. You will need to provide your own icons for the rest of the app.

packages/vuetify/src/iconsets/mat.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Composables
2+
import { VLigatureIcon } from '@/composables/icons'
3+
4+
// Utilities
5+
import { h } from 'vue'
6+
7+
// Types
8+
import type { IconAliases, IconSet } from '@/composables/icons'
9+
10+
const aliases: IconAliases = {
11+
collapse: 'keyboard_arrow_up',
12+
complete: 'check',
13+
cancel: 'cancel',
14+
close: 'close',
15+
delete: 'cancel', // delete (e.g. v-chip close)
16+
clear: 'cancel',
17+
success: 'check_circle',
18+
info: 'info',
19+
warning: 'priority_high',
20+
error: 'warning',
21+
prev: 'chevron_left',
22+
next: 'chevron_right',
23+
checkboxOn: 'check_box',
24+
checkboxOff: 'check_box_outline_blank',
25+
checkboxIndeterminate: 'indeterminate_check_box',
26+
delimiter: ['M12 19q-2.925 0-4.962-2.037T5 12t2.038-4.962T12 5t4.963 2.038T19 12t-2.037 4.963T12 19'], // for carousel
27+
sortAsc: 'arrow_upward',
28+
sortDesc: 'arrow_downward',
29+
expand: 'keyboard_arrow_down',
30+
menu: 'menu',
31+
subgroup: 'arrow_drop_down',
32+
dropdown: 'arrow_drop_down',
33+
radioOn: 'radio_button_checked',
34+
radioOff: 'radio_button_unchecked',
35+
edit: 'edit',
36+
ratingEmpty: 'star_border',
37+
ratingFull: ['m5.825 21l1.625-7.025L2 9.25l7.2-.625L12 2l2.8 6.625l7.2.625l-5.45 4.725L18.175 21L12 17.275z'],
38+
ratingHalf: 'star_half',
39+
loading: 'cached',
40+
first: 'first_page',
41+
last: 'last_page',
42+
unfold: 'unfold_more',
43+
file: 'attach_file',
44+
plus: 'add',
45+
minus: 'remove',
46+
calendar: 'event',
47+
treeviewCollapse: 'arrow_drop_down',
48+
treeviewExpand: 'arrow_right',
49+
eyeDropper: 'colorize',
50+
}
51+
52+
function mat (type: 'outlined' | 'rounded' | 'sharp'): IconSet {
53+
return {
54+
component: props => h(VLigatureIcon, { ...props, class: `material-symbols-${type}` }),
55+
}
56+
}
57+
58+
export { aliases, mat }

0 commit comments

Comments
 (0)