Unplugin Svg Component screenshot

Unplugin Svg Component

Author Avatar Theme by Jevon617
Updated: 11 Nov 2025
70 Stars

generate a vue/react component through svg files, supporting svg file HMR, Tree-shaking, SSR and TS hint.

Categories

Overview

Unplugin-svg-component is an innovative tool that streamlines the process of utilizing SVG files in modern web development. Designed for both Vue and React, this plugin simplifies the integration of SVG icons by generating components directly from SVG files. It enhances the developer experience with features such as intelligent naming through TypeScript, enabling smoother workflow and faster component development.

This plugin distinguishes itself by supporting Hot Module Replacement (HMR) and tree-shaking functionalities, allowing developers to bundle only the essential icons and improve application performance. Whether you’re adapting SVGs for intricate UI designs in Vue or React applications, unplugin-svg-component offers a robust solution to incorporate scalable and stylish vector graphics.

Features

  • Intelligent Naming: The plugin intelligently prompts the SVG file names during component usage, providing seamless integration with TypeScript.

  • Hot Module Replacement (HMR): With HMR support for SVG files, developers can see real-time updates without needing a full page reload, enhancing the development experience.

  • Framework Compatibility: Unplugin-svg-component supports both Vue and React, automatically detecting the project type to streamline usage.

  • Tree-shaking: Since version 0.5.0, this feature ensures that only the necessary icons are bundled, optimizing the application size and performance.

  • Server-Side Rendering (SSR): Enhanced SSR support is available by enabling specific options, ensuring that SVGs render correctly on the server-side since version 0.6.0.

  • Flexible Configuration: Customizable parameters allow developers to specify icon directories, component names, styles, and more, adapting to various project needs.

  • Preserve Original Colors: The plugin can retain original SVG colors with an option for regular expression matching, offering greater design flexibility.

  • Optimization Options: Built-in SVGO optimization capabilities ensure that SVG files are optimized for performance without sacrificing quality.