Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
U

unplugin-icons

> 前端框架
Open source

Access thousands of icons as components on-demand universally.

4.9K stars0 likes0 views
WebsiteGitHub

About

Access thousands of icons as components on-demand universally.

unplugin-icons

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, Vue Vapor, 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 - a blog post by Anthony   

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

From v24.0.0 unplugin-icons requires Node 20 or above: unplugin v3.0.0 requires Node 20 or above.

Quick Start

Basic Usage

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

React Example:

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

function App() {
  return (
    

  )
}

Vue Example:

xml
<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

bash
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)

bash
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:

bash
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:

typescript
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
typescript
// vite.config.ts
import Icons from 'unplugin-icons/vite'

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


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

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


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

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


Nuxt

Nuxt 2 and Nuxt Bridge

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

Nuxt 3/4

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

Or work with unplugin-vue-components resolvers

typescript
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
typescript
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).

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

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


SvelteKit

Add to your vite.config.ts:

typescript
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:

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

Add to your vite.config.ts:

typescript
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:

typescript
// 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:

typescript
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
typescript
// esbuild.config.js
import { build } from 'esbuild'
import Icons from 'unplugin-icons/esbuild'

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


Astro
typescript
// 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.

typescript
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:

typescript
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:

bash
npm i -D @vue/compiler-sfc

TypeScript Support:

Add to your tsconfig.json:

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

See the Vue 3 example for a complete setup.


Vue Vapor

Emits Vapor mode components instead of virtual-DOM ones. An app mounted with createVaporApp and no VDOM interop plugin renders a virtual-DOM icon as nothing at all — no error, no warning — so a Vapor app needs this compiler rather than vue3.

Configuration:

typescript
Icons({ compiler: 'vue-vapor' })

Peer Dependency:

Requires Vue 3.6+:

bash
npm i -D @vue/compiler-vapor

TypeScript Support:

Add to your tsconfig.json:

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


React

Configuration:

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

Peer Dependencies:

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

TypeScript Support:

Add to your tsconfig.json:

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

See the React example for a complete setup.


Preact

Configuration:

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

Peer Dependencies:

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

TypeScript Support:

Add to your tsconfig.json:

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

See the Preact example for a complete setup.


Solid

Configuration:

typescript
Icons({ compiler: 'solid' })

TypeScript Support:

Add to your tsconfig.json:

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

See the Solid example for a complete setup.


Svelte

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScripticonifyiconsjsxnuxt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架