Add 7,000+ icons to your Nuxt project, from Material Design Icons.
- Add 7,000+ icons, from Material Design Icons.
- TypeScript completion.
- Zero imports needed.
Install the nuxt-mdi
dependency to your project using your preferred package manager:
pnpm add -D nuxt-mdi
yarn add --dev nuxt-mdi
npm install --save-dev nuxt-mdi
Add 'nuxt-mdi'
to the modules
section of your nuxt.config.ts
file.
export default defineNuxtConfig({
modules: [
'nuxt-mdi'
]
})
That's it! You can now use nuxt-mdi in your Nuxt app ✨
The module will automatically make the MdiIcon
component available to your app. You can use it like this:
<MdiIcon icon="mdiAccount" />
icon
(required): The name of the icon to display.flipX
(optional): Flip the icon on the X axis.flipY
(optional): Flip the icon on the Y axis.
You can configure this module by adding an mdi
section to the nuxt.config.ts
file.
export default defineNuxtConfig({
// ...
mdi: {
cache: false,
componentName: 'MdiIcon',
defaultSize: '1em'
}
})
Once an icon is loaded, it is automatically cached in localStorage. This means that the icon will be loaded from localStorage instead of the network on subsequent requests. This is enabled by default, but can be disabled by setting cache
to false
.
By default, the component name is MdiIcon
. You can change this by setting the componentName
option.
export default defineNuxtConfig({
// ...
mdi: {
componentName: 'MyIcon'
}
})
<MyIcon icon="mdiAccount" />
By default, the icons will be rendered at 1em
. You can change this by setting the defaultSize
option.
You can find available icons on the Material Design Icons website. IntelliSense will automatically display auto completion for the available icons.
If you are using VS Code, you can use the Vue Language Features (Volar) extension to get IntelliSense for Vue components.