TDesign Icons for Vue 2

0.4.4 · active · verified Sun Apr 19

tdesign-icons-vue provides a comprehensive set of icons specifically designed for Vue 2.x applications, serving as the official icon library within the TDesign enterprise design system. It offers flexibility in usage, allowing developers to import icons as SVG sprite components (Icon), icon font components (IconFont), or individual, tree-shakeable Vue components. The library is actively maintained as part of a mono-repo (`Tencent/tdesign-icons`), with a corresponding `tdesign-icons-vue-next` package available for Vue 3.x projects. The project observes a frequent release cadence, with regular patch and minor updates introducing new icons or optimizations, alongside occasional major version changes that may include icon renames or removals. Its key differentiators include tight integration with the TDesign ecosystem, multiple rendering options, and built-in TypeScript support.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install and use TDesign icons in a Vue 2 application, showcasing global registration of SVG sprite icons, usage of the IconFont component (with a note about CSS), and direct import of individual icon components.

import Vue from 'vue';
import { Icon, IconFont, CloseIcon, TimeIcon } from 'tdesign-icons-vue';

// Globally register the SVG sprite icon component
Vue.component('TIcon', Icon);

// Optionally, globally register the IconFont component
// Vue.component('TIconFont', IconFont);

new Vue({
  el: '#app',
  components: { CloseIcon, TimeIcon, IconFont },
  template: `
    <div id="app">
      <h1>TDesign Icons for Vue 2</h1>
      <h2>SVG Sprite Icon</h2>
      <TIcon name="close" size="24px" style="color: #f00;" />
      <TIcon name="time" size="32px" style="color: #00f;" />
      
      <h2>Icon Font (requires external CSS for font-face)</h2>
      <!-- Ensure the iconfont CSS is loaded globally, e.g., in your main.js or index.html -->
      <!-- Example: <link rel="stylesheet" href="path/to/tdesign-iconfont.css"> -->
      <IconFont name="setting" size="20px" />
      <IconFont name="file" size="28px" />

      <h2>Individual Icon Components</h2>
      <CloseIcon size="24px" style="margin-left: 10px;" />
      <TimeIcon size="24px" />
    </div>
  `
});

view raw JSON →