nuxt-mdi
Nuxt mdi
Add 7,000+ icons to your Nuxt project, from Material Design Icons.
Features
- Add 7,000+ icons, from Material Design Icons.
- TypeScript completion.
- Zero imports needed.
Getting Started
Installation
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
Activation
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 ✨
Usage
The module will automatically make the MdiIcon
component available to your app. You can use it like this:
<MdiIcon icon="mdiAccount" />
Props:
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.
Configuration
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'
}
})
Cache: cache
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
.
Component name: componentName
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" />
Default size: defaultSize
By default, the icons will be rendered at 1em
. You can change this by setting the defaultSize
option.
Icons
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.