MCPcopy
hub / github.com/unplugin/unplugin-icons

github.com/unplugin/unplugin-icons @v23.0.1 sqlite

repository ↗ · DeepWiki ↗ · release v23.0.1 ↗
65 symbols 236 edges 124 files 0 documented · 0%
README

unplugin-icons

NPM version

Access thousands of icons as components on-demand universally.

Features

  • 🌏 Universal
  • 🤹 Any icon sets - ~150 popular sets with over 200,000 icons, logos, emojis, etc. Powered by Iconify.
  • 📦 Major build tools - Vite, Webpack, Rollup, Nuxt, Rspack, etc. Powered by unplugin.
  • 🚀 Major frameworks - Vanilla, Web Components, React, Vue 3, Solid, Svelte, and more. Contribute.
  • 🍱 Any combinations of them!
  • ☁️ On-demand - Only bundle the icons you really use, while having all the options.
  • 🖨 SSR / SSG friendly - Ship the icons with your page, no more FOUC.
  • 🌈 Stylable - Change size, color, or even add animations as you would with styles and classes.
  • 📥 Custom icons - load your custom icons to get universal integrations at ease.
  • 📲 Auto Importing - Use icons as components directly in your template.
  • 🦾 TypeScript support.
  • 🔍 Browse Icons
   💡 **Story behind this tool**: [Journey with Icons Continues](https://antfu.me/posts/journey-with-icons-continues) - a blog post by Anthony   

vite-plugin-icons has been renamed to unplugin-icons, see the migration guide

Quick Start

Basic Usage

Import icons using the convention ~icons/{collection}/{icon} and use them as components. Auto importing is also supported.

React Example:

import IconAccessibility from '~icons/carbon/accessibility'
import IconAccountBox from '~icons/mdi/account-box'

function App() {
  return (



      <IconAccessibility />
      <IconAccountBox style={{ fontSize: '2em', color: 'red' }} />



  )
}

Vue Example:

<script setup>
import IconAccessibility from '~icons/carbon/accessibility'
import IconAccountBox from '~icons/mdi/account-box'
</script>

<template>
  <icon-accessibility />
  <icon-account-box style="font-size: 2em; color: red" />
</template>

Installation

Note: This package is ESM-only. Make sure your project uses ES modules ("type": "module" in package.json or .mjs file extensions).

Step 1: Install the Plugin

npm i -D unplugin-icons

Step 2: Install Icon Data

We use Iconify as the icons data source (supports 100+ icon sets).

[!TIP] ✨ VS Code Users: Install the Iconify IntelliSense extension for inlay preview, auto-completion, and hover information.

Option A: Install Full Collection (Recommended for flexibility)

npm i -D @iconify/json

This installs all icon sets (~120MB). Only icons you actually use will be bundled in production.

Option B: Install Individual Icon Sets

Install only the icon sets you need:

npm i -D @iconify-json/mdi @iconify-json/carbon

Option C: Auto Install (Experimental)

Let unplugin-icons automatically install icon sets when you import them:

Icons({
  autoInstall: true, // Auto-detects npm/yarn/pnpm
})

Examples

Check out the playgrounds page to try examples online in StackBlitz.

Available examples: - Vite + Vue 3 - Vite + React - Next.js - Nuxt 4 - SvelteKit - Astro - And more...

Configuration

This section covers how to configure unplugin-icons for different build tools and frameworks.

Build Tools

Vite

// vite.config.ts
import Icons from 'unplugin-icons/vite'

export default defineConfig({
  plugins: [
    Icons({ /* options */ }),
  ],
})

Rollup

// rollup.config.js
import Icons from 'unplugin-icons/rollup'

export default {
  plugins: [
    Icons({ /* options */ }),
  ],
}

Webpack

// webpack.config.mjs
import Icons from 'unplugin-icons/webpack'

export default {
  /* ... */
  plugins: [
    Icons({ /* options */ }),
  ],
}

Nuxt

Nuxt 2 and Nuxt Bridge

// nuxt.config.ts
export default {
  buildModules: [
    ['unplugin-icons/nuxt', { /* options */ }],
  ],
}

Nuxt 3/4

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    ['unplugin-icons/nuxt', { /* options */ }]
  ],
})

Or work with unplugin-vue-components resolvers

import IconsResolver from 'unplugin-icons/resolver'
import ViteComponents from 'unplugin-vue-components/vite'

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'unplugin-icons/nuxt',
  ],
  vite: {
    plugins: [
      ViteComponents({
        resolvers: [
          IconsResolver({/* options */}),
        ],
      }),
    ],
  },
})

See the Nuxt example for a working example project.

Rspack

import Icons from 'unplugin-icons/rspack'

// rspack.config.mjs
export default defineConfig({
  plugins: [
    // ...
    Icons({/* options */}),
  ]
})

Vue CLI

Note: This package is ESM-only. You need to use vue.config.mjs with ES module syntax (requires @vue/cli-service ^5.0.8).

// vue.config.mjs
import Icons from 'unplugin-icons/webpack'

export default {
  configureWebpack: {
    plugins: [
      Icons({ /* options */ }),
    ],
  },
}

SvelteKit

Add to your vite.config.ts:

import { sveltekit } from '@sveltejs/kit/vite'
import Icons from 'unplugin-icons/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    sveltekit(),
    Icons({
      compiler: 'svelte',
    })
  ]
})

Check instructions in the Frameworks -> Svelte section below if you faced module import errors.

See the SvelteKit example for a working example project.

Svelte + Vite

Svelte support requires the @sveltejs/vite-plugin-svelte plugin:

npm i -D @sveltejs/vite-plugin-svelte

Add to your vite.config.ts:

import { svelte } from '@sveltejs/vite-plugin-svelte'
import Icons from 'unplugin-icons/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    svelte(),
    Icons({
      compiler: 'svelte',
    }),
  ],
})

Check instructions in the Frameworks -> Svelte section below if you faced module import errors.

See the Svelte + Vite example for a working example project.

Next.js

Note: This package is ESM-only. You need to use next.config.mjs with ES module syntax.

Add to your next.config.mjs:

// next.config.mjs
import Icons from 'unplugin-icons/webpack'

/** @type {import('next').NextConfig} */
export default {
  reactStrictMode: true,
  webpack(config) {
    config.plugins.push(
      Icons({
        compiler: 'jsx',
        jsx: 'react'
      })
    )

    return config
  }
}

Check instructions in the Frameworks -> React section below if you faced module import errors.

⚠️ Warning: to import an icon is necessary to explicitly add the .jsx extension to the import path, so that Next.js knows how to load it, by example:

import IconArrowRight from '~icons/dashicons/arrow-right.jsx';
                                                     // ^-- write `.jsx` to avoid
                                                     // https://github.com/antfu/unplugin-icons/issues/103
// ...some code later
<IconArrowRight />

See the Next.js example for a working example project.

esbuild

// esbuild.config.js
import { build } from 'esbuild'
import Icons from 'unplugin-icons/esbuild'

build({
  /* ... */
  plugins: [
    Icons({
      /* options */
    }),
  ],
})

Astro

// astro.config.mjs
import { defineConfig } from 'astro/config'
import Icons from 'unplugin-icons/vite'

// https://astro.build/config
export default defineConfig({
  vite: {
    plugins: [
      Icons({
        compiler: 'astro',
      }),
    ],
  },
})

See the Astro example for a working example project.

Astro + Vue

Required @astrojs/vue installed.

import Vue from '@astrojs/vue'
// astro.config.mjs
import { defineConfig } from 'astro/config'
import Icons from 'unplugin-icons/vite'

// https://astro.build/config
export default defineConfig({
  integrations: [
    Vue(),
  ],
  vite: {
    plugins: [
      Icons({
        compiler: 'vue3',
      }),
    ],
  },
})

See the Astro + Vue example for a working example project.

Frameworks

Configure the compiler option based on your framework. Some frameworks may require additional peer dependencies.

Vue 3

Configuration:

Icons({ compiler: 'vue3' })

Peer Dependency:

Note: As of Vue 3.2.13+, @vue/compiler-sfc is included in the main vue package, so no additional installation is needed.

If you're using an older version:

npm i -D @vue/compiler-sfc

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/vue"
    ]
  }
}

See the Vue 3 example for a complete setup.

React

Configuration:

Icons({ compiler: 'jsx', jsx: 'react' })

Peer Dependencies:

npm i -D @svgr/core @svgr/plugin-jsx

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/react"
    ]
  }
}

See the React example for a complete setup.

Preact

Configuration:

Icons({ compiler: 'jsx', jsx: 'preact' })

Peer Dependencies:

npm i -D @svgr/core @svgr/plugin-jsx

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/preact"
    ]
  }
}

See the Preact example for a complete setup.

Solid

Configuration:

Icons({ compiler: 'solid' })

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/solid"
    ]
  }
}

See the Solid example for a complete setup.

Svelte

Configuration:

Icons({ compiler: 'svelte' })

TypeScript Support:

For SvelteKit, add to src/app.d.ts:

import 'unplugin-icons/types/svelte'

For Svelte + Vite, add to src/vite-env.d.ts:

/// <reference types="svelte" />
/// <reference types="vite/client" />
/// <reference types="unplugin-icons/types/svelte" />

For Svelte 4, use:

/// <reference types="unplugin-icons/types/svelte4" />

For Svelte 3, use:

/// <reference types="unplugin-icons/types/svelte3" />

See the Svelte example for a complete setup.

Astro

Configuration:

Icons({ compiler: 'astro' })

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/astro"
    ]
  }
}

See the Astro example for a complete setup.

Astro + Vue

Configuration:

Icons({ compiler: 'vue3' })

Requirements:

Requires @astrojs/vue to be installed.

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/vue"
    ]
  }
}

See the Astro + Vue example for a complete setup.

Qwik

Option 1: Native Qwik Compiler (Recommended)

Configuration:

Icons({ compiler: 'qwik' })

Peer Dependency:

npm i -D @svgx/core

Option 2: JSX Compiler

Configuration:

Icons({ compiler: 'jsx', jsx: 'qwik' })

Peer Dependencies:

npm i -D @svgr/core @svgr/plugin-jsx

TypeScript Support:

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "unplugin-icons/types/qwik"
    ]
  }
}

See the Qwik example for a complete setup.

Ember

Configuration:

Icons({ compiler: 'ember' })

Build Tool Support:

Ember works with either Webpack or Vite.

For Vite applications, add to vite.config.mjs:

```ts import { ember, extensions } from '@embroider/vite' import { babel } from '@rollup/plugin-babel' import Icons from 'unplugin-icons/vite' import { defineConfig } from 'vite'

export default defineConfig({ plugins: [ ember(), Icons({ compiler: 'ember', }), babel({ babelHelpers: 'runtime',

Extension points exported contracts — how you extend this code

ComponentResolverOption (Interface)
(no doc)
src/resolver.ts
Options (Interface)
(no doc)
src/types.ts
ResolvedIconPath (Interface)
(no doc)
src/core/loader.ts
GlobalComponents (Interface)
(no doc)
examples/vite-vue3-legacy/components.d.ts
GlobalComponents (Interface)
(no doc)
examples/vite-vue3/components.d.ts
GlobalComponents (Interface)
(no doc)
examples/nuxt4/app/components.d.ts
CustomCompiler (Interface)
(no doc)
src/core/compilers/types.ts

Core symbols most depended-on inside this repo

isIconPath
called by 3
src/core/loader.ts
FileSystemIconLoader
called by 2
src/loaders.ts
ExternalPackageIconLoader
called by 2
src/loaders.ts
handleSVGId
called by 2
src/core/svgId.ts
resolveIconsPath
called by 2
src/core/loader.ts
getDtsTypesFiles
called by 1
tsdown.config.ts
normalizeIconPath
called by 1
src/core/loader.ts
generateComponent
called by 1
src/core/loader.ts

Shape

Function 46
Class 12
Interface 7

Languages

TypeScript100%

Modules by API surface

src/core/loader.ts7 symbols
src/core/options.ts4 symbols
examples/vite-ember/app/app.ts4 symbols
src/index.ts3 symbols
types/svelte4.d.ts2 symbols
types/svelte3.d.ts2 symbols
tsdown.config.ts2 symbols
src/resolver.ts2 symbols
src/loaders.ts2 symbols
examples/webpack-ember/app/router.js2 symbols
examples/webpack-ember/app/app.js2 symbols
examples/vite-svelte/vite.config.js2 symbols

Dependencies from manifests, versioned

@antfu/install-pkg1.1.0 · 1×
@antfu/utils9.3.0 · 1×
@astrojs/vue5.1.4 · 1×
@babel/core7.28.6 · 1×
@babel/plugin-transform-runtime7.28.5 · 1×
@babel/plugin-transform-typescript7.28.6 · 1×
@babel/runtime7.28.6 · 1×
@builder.io/qwik1.2.10 · 1×
@ember/app-tsconfig2.0.0 · 1×
@ember/optional-features2.3.0 · 1×
@embroider/compat3.9.3 · 1×

For agents

$ claude mcp add unplugin-icons \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact