Skip to content

Commit 55263c5

Browse files
committed
docs: add Vuetify 4 UnoCSS preset icons usage guide
1 parent dde09d0 commit 55263c5

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

docs/guide/features/icons/unocss-preset-icons.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,75 @@ Once the UnoCSS Nuxt Module and UnoCSS Preset Icons are installed and configured
66

77
UnoCSS Preset Icons use [Iconify](https://iconify.design/) as their icon data source. You need to install the corresponding icon set in `devDependencies` following the `@iconify-json/*` pattern. For example, `@iconify-json/mdi` for [Material Design Icons](https://materialdesignicons.com/), `@iconify-json/tabler` for [Tabler](https://tabler-icons.io/). You can refer to [Icônes](https://icones.js.org/) or [Iconify](https://icon-sets.iconify.design/) for all available collections.
88

9+
## Vuetify 4 built-in UnoCSS icon sets
10+
11+
Vuetify 4 provides pre-configured icon sets that work with UnoCSS Preset Icons. You can find the full list of available icon sets in the [Vuetify documentation](https://vuetifyjs.com/en/features/icon-fonts/#unocss-icon-sets).
12+
13+
To use these built-in icon sets, you need to set the `defaultSet` to `custom` in your Nuxt configuration file and register the icon set in a custom Nuxt plugin.
14+
15+
For example, to use the Phosphor (`ph`) icon set:
16+
17+
1. Install the required dependencies:
18+
::: code-group
19+
20+
```bash [npm]
21+
npm i -D @iconify-json/ph @unocss/nuxt
22+
```
23+
24+
```bash [yarn]
25+
yarn add -D @iconify-json/ph @unocss/nuxt
26+
```
27+
28+
```bash [pnpm]
29+
pnpm add -D @iconify-json/ph @unocss/nuxt
30+
```
31+
32+
```bash [bun]
33+
bun add -D @iconify-json/ph @unocss/nuxt
34+
```
35+
36+
:::
37+
38+
2. Configure the default set in your Nuxt configuration file:
39+
::: code-group
40+
41+
```ts [nuxt.config.ts]
42+
import { defineNuxtConfig } from 'nuxt/config'
43+
44+
export default defineNuxtConfig({
45+
modules: ['@unocss/nuxt', 'vuetify-nuxt-module'],
46+
vuetify: {
47+
vuetifyOptions: {
48+
icons: {
49+
defaultSet: 'custom'
50+
}
51+
}
52+
}
53+
})
54+
```
55+
56+
:::
57+
58+
3. Create a new Nuxt plugin to register the icon set:
59+
::: code-group
60+
61+
```ts [plugins/vuetify-icons.ts]
62+
import { ph, aliases } from 'vuetify/iconsets/ph'
63+
import { defineNuxtPlugin } from '#imports'
64+
65+
export default defineNuxtPlugin((nuxtApp) => {
66+
nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
67+
vuetifyOptions.icons = {
68+
defaultSet: 'ph',
69+
aliases,
70+
sets: { ph },
71+
}
72+
})
73+
})
74+
```
75+
76+
:::
77+
978
## Using UnoCSS Preset Icons
1079

1180
UnoCSS Preset Icons allows you to use any icon via `v-icon`. You need to register the `mdi` icon set to allow Vuetify to configure the icon via the `class` attribute:

0 commit comments

Comments
 (0)