json-package


目录

title: Exporting JSON Packages
types:
  IconSet: '../icon-set/index.md'
  IconifyJSON: '/docs/types/iconify-json.md'

Exporting icon set as JSON package

This tutorial is part of export functions documentation in Iconify Tools.

Function [func]exportJSONPackage() creates an icon package in specified directory.

These packages are used to load an entire icon sets, like this:

import { addCollection, Icon } from '@iconify/react';
import { icons as mdiLightIcons } from '@iconify-json/mdi-light';
import { icons as tablerIcons } from '@iconify-json/tabler';

addCollection(mdiLightIcons);
addCollection(tablerIcons);

// Demo using some of imported icons
export function renderHomeIcon() {
	return <Icon icon="mdi-light:home" />;
}

export function renderAlertIcon() {
	return <Icon icon="tabler:alert-octagon" />;
}

[npm]@iconify-json/mdi-light and [npm]@iconify-json/tabler are packages generated by this function, used in example above.

See individual icon set packages documentation for details.

Usage

Function has the following parameters:

Function returns array of generated files.

Function is asynchronous. That means you need to handle it as [class]Promise instance, usually by adding [js]await before function call.

Options

Options object has the following mandatory property:

and the following optional properties:

customFiles

[prop]customFiles option contains additional files you want to add to package. Key is filename, value can be one of these types:

Example

src: libraries/tools/export/json-package.ts
title: 'example.ts'

版本号 #2
由 壳壳虫 创建于 2026-10-31 14:24:47 UTC
由 壳壳虫 更新于 2026-10-31 14:24:48 UTC