icon
@nuxt/icon

200,000+ ready to use icons from Iconify.

Features

  • SSR friendly
  • Support 200,000 open-source vector icons via Iconify
  • Support both CSS mode / SVG mode
  • Custom SVG support (via Vue component, or via local SVG files)

Installation

Run the following command to add the module to your project, with the nuxt add command:

npx nuxt add icon

That's it, you can now use the <Icon /> in your components, see Usage.

✨ If you are using VS Code, you can use the Iconify IntelliSense extension by @antfu

Manual Setup

You can install the module manually with:

npm i @nuxt/icon

Update your nuxt.config.ts

export default defineNuxtConfig({
  modules: [
    '@nuxt/icon'
  ]
})

If you have the legacy module nuxt-icon installed, you might want to remove it from the modules list.

Vite (without Nuxt)

If you are building a plain Vue app with Vite (for example when using Nuxt UI's Vue integration), there is no Nuxt server to serve icons from, and @iconify/vue would fetch icons from the Iconify API at runtime. To render icons offline without network requests, @nuxt/icon ships a standalone Vite plugin that pre-bundles the icons you use into the client build.

Install it with @iconify/vue, which the registration module imports, and the icon collections you use:

npm i @nuxt/icon @iconify/vue
npm i -D @iconify-json/uil @iconify-json/heroicons

Then add the plugin to your Vite config:

// vite.config.ts
import { defineConfig } from 'vite'
import { NuxtIconBundle } from '@nuxt/icon/vite'

export default defineConfig({
  plugins: [
    NuxtIconBundle({
      // Explicitly pre-bundle known icons (hard-fails the build when missing locally)
      icons: ['uil:github', 'heroicons:home'],
      // Scanning your source files for icon usages is enabled by default.
      // It reads .vue, .jsx, .tsx, Markdown and YAML files: list icons only named in .js/.ts files in `icons`.
      scan: true,
    }),
  ],
})

Then register the bundled icons once in your entry file:

// main.ts
import 'virtual:nuxt-icon-bundle/register'

Add the type shims for the virtual modules to the types of your tsconfig.json, next to the ones you already list:

{
  "compilerOptions": {
    "types": ["vite/client", "@nuxt/icon/client"]
  }
}

The plugin accepts the same options as icon.clientBundle (icons, scan, sizeLimitKb), plus customCollections — with two differences in defaults: scan is enabled by default (bundling is the whole point of the plugin), and includeCustomCollections is always enabled by default (there is no server provider to fall back to).

For library and framework authors integrating icons themselves: virtual:nuxt-icon-bundle exports init(addIcon) so you can register the bundled data on your own copy of @iconify/vue (or any compatible store), and the underlying primitives (IconUsageScanner, resolveBundleIcons, generateClientBundleCode, ...) are exported from @nuxt/icon/utils.

For server-side rendering, @iconify/vue has its own requirements: see its documentation.

See playgrounds/vite/ for a working example (pnpm play:vite to run it locally).