IconPark Documentation
repository·master·Indexed 27 days ago
https://github.com/bytedance/iconparkAn icon library featuring over 2000 high-quality icons with a system for transforming a single SVG source into multiple themes: outline, filled, two-tone, and multi-color. It provides dedicated packages for React (@icon-park/react), Vue 2 (@icon-park/vue), Vue 3 (@icon-park/vue-next), and pure SVG (@icon-park/svg). Supports tree-shaking, on-demand loading via babel-plugin-import, and global configuration through IconProvider or setConfig.
What's inside IconPark
- IconPark provides over 2000 high-quality icons with an innovative technology that allows theme switching by changing SVG attributes. It supports multiple framework integrations for on-demand component usage.
Install @icon-park/vue-next
masterInstall the IconPark Vue Next package using npm to use the icon system in your Vue project.
npm install @icon-park/vue-next --saveInstall @icon-park/react
masterInstall the IconPark React package using npm to use the icon system in your React projects.
npm install @icon-park/react --saveConfigure global icon settings via provide
masterYou can set global configuration for all icons by using Vue's
provideAPI with theICON_CONFIGSkey. This allows you to override default settings like theprefixglobally.<template> <div> <home/> </div> </template> <script lang="ts"> import {DEFAULT_ICON_CONFIGS} from '@icon-park/vue' import {Home} from '@icon-park/vue'; const IconConfig = {...DEFAULT_ICON_CONFIGS, prefix: 'icon'} export default { name: 'App', provide () { return { ICON_CONFIGS: IconConfig } }, components: { Home } }; </script>Customize icon themes and colors
masterIconPark uses a technology that transforms a single SVG source into multiple themes by adjusting
fillandstrokeattributes. You can switch between the following themes:outlinefilledtwo-tonemulti-color
Coloring Rules:
- Basic coloring: Set the
fillattribute.fillsets the color inside the object, whilestrokesets the color of the lines. - Two-tone/Multi-color: Pass an array of colors to the
fillprop to apply different colors to different parts of the icon.
Install IconPark in Vue 2 or Vue 3
masterFor Vue 2 and Vue 3 users, theinstallmethod is available to facilitate library installation (introduced inv1.1.5).Configure Import on Demand with babel-plugin-import
masterTo reduce bundle size, use
babel-plugin-importto load icons on demand. Configure your Babel settings as follows:{ "plugins": [ [ "import", { "libraryName": "@icon-park/vue", "libraryDirectory": "es/icons", "camel2DashComponentName": false } ] ] }Install IconPark packages for React, Vue, or SVG
masterDepending on your project type, you can install the corresponding NPM package:
- React:
@icon-park/react - Vue 2:
@icon-park/vue - Vue 3:
@icon-park/vue-next - Pure SVG:
@icon-park/svg
- React:
Import IconPark style sheets
masterTo ensure icons are styled correctly, import the required CSS or Less files at the entry point of your application.
import '@icon-park/react/styles/index.css'; // or import '@icon-park/react/styles/index.less';Install IconPark globally
masterTo avoid manual imports for every icon, you can install IconPark globally in your Vue app. This allows you to use icons via a prefix (e.g.,
icon-peoplefor thePeopleicon).By default, the prefix is
icon. You can specify a custom prefix as the second argument toinstall().import {install} from '@icon-park/vue-next/es/all'; import {createApp} from 'vue'; const app = createApp({}); // Install with default prefix 'icon' (e.g., <icon-people />) install(app); // Install with custom prefix 'i' (e.g., <i-people />) install(app, 'i'); app.mount('#app');Install icons globally
masterTo use icons globally without manual imports in every component, use the
installmethod from@icon-park/vue-next/es/all.By default, the component prefix is
icon(e.g.,Peoplebecomesicon-people). You can provide a custom prefix as the second argument toinstall(e.g.,imakes iti-people).import {install} from '@icon-park/vue-next/es/all'; import {createApp} from 'vue'; const app = createApp({}); // Install with default prefix 'icon' install(app); // Install with custom prefix 'i' install(app, 'i'); app.mount('#app');Enable on-demand loading with babel-plugin-import
masterTo reduce bundle size, use
babel-plugin-importto load icons on demand. Configure the plugin in your Babel configuration as follows:{ "plugins": [ [ "import", { "libraryName": "@icon-park/react", "libraryDirectory": "es/icons", "camel2DashComponentName": false } ] ] }