2
0
mirror of https://github.com/iconify/collections-json.git synced 2024-11-25 06:07:39 +00:00
Go to file
2021-11-03 21:37:23 +02:00
.vscode chore: add vscode stuff and .editorconfig 2021-09-23 11:03:10 +02:00
jest test: hacking cjs tests 2021-09-18 14:42:03 +02:00
json Update Akar Icons, Bootstrap Icons, IonIcons, Noto Emoji 2021-11-03 08:58:53 +02:00
lib chore: refactor 2021-09-16 15:33:04 +02:00
src Use @iconify/types for types, convert info, publish next version 2021-09-30 11:59:53 +03:00
.editorconfig Change formatting rules to work with Prettier 2021-09-25 14:17:12 +03:00
.eslintignore chore: add .eslintigonore 2021-09-18 14:50:23 +02:00
.eslintrc.json Change formatting rules to work with Prettier 2021-09-25 14:17:12 +03:00
.gitignore feat: add esm support 2021-09-13 17:57:27 +02:00
.npmignore Add .npmignore 2021-09-30 12:02:09 +03:00
.prettierignore Change formatting rules to work with Prettier 2021-09-25 14:17:12 +03:00
.prettierrc Change formatting rules to work with Prettier 2021-09-25 14:17:12 +03:00
collections.json Merge remote-tracking branch 'origin/master' into next 2021-11-03 21:35:25 +02:00
collections.md Update Akar Icons, Bootstrap Icons, IonIcons, Noto Emoji 2021-11-03 08:58:53 +02:00
composer.json Update Akar Icons, Bootstrap Icons, IonIcons, Noto Emoji 2021-11-03 08:58:53 +02:00
jest.cjs.config.ts test: hacking cjs tests 2021-09-18 14:42:03 +02:00
jest.esm.config.ts test: hacking cjs tests 2021-09-18 14:42:03 +02:00
package.json Make sure package is published with tag 'next' until Iconify Tools rewrite is done 2021-11-03 21:37:23 +02:00
readme.md Fix syntax highlighting 2020-07-18 02:12:35 -04:00
tsconfig.json Use @iconify/types for types, convert info, publish next version 2021-09-30 11:59:53 +03:00
yarn.lock Use @iconify/types for types, convert info, publish next version 2021-09-30 11:59:53 +03:00

Iconify icons collection in JSON format

This is collection of SVG icons created by various authors, released under various free licenses. Some collections require attribution when used for commercial purposes. See collections.md for list of collections and their licenses.

All SVG icons have been cleaned up. Content has been optimized, colors for monotone icons have been replaced with currentColor, ready to be inserted in HTML. Tools used for creating this collection are available on Iconify GitHub repository, more specifically @iconify/tools. You can use it to create your own JSON packages from custom icon sets.

This library is intended to be used in packages that build components, such as Iconify Tools and Iconify React.

Repository is updated daily by fully automated script, so it always contains latest icons from various sources.

How to get this repository

Instructions below are for Node.js and PHP projects.

Node.js

Run this command to add icons to your project:

npm install --save @iconify/json

Icons will be available in node_modules/@iconify/json

To resolve filename for any json file, use this:

const icons = require('@iconify/json');

// returns location of fa.json
let fa = icons.locate('fa');

PHP

Install and initialize Composer project. See documentation at https://getcomposer.org

Then open composer.json and add following code:

"require": {
    "php": ">=5.6",
    "iconify/json": "*"
}

then run:

composer install

Icons will be available in vendor/iconify/json/

If you don't use Composer, clone GitHub repository and add necessary autoload code.

To resolve filename for any json file, use this:

// returns location of fa.json
$fa = \Iconify\IconsJSON\Finder::locate('fa');

Format

Icons used by Iconify are in directory json, in Iconify JSON format.

Why JSON instead of SVG? To load images in bulk.

If you need individual SVG images, you can generate them using Iconify JSON Tools. See instructions for PHP version or Node.js version.

Format of json file is very simple:

{
    "icons": {
        "icon-name": {
            "body": "svg body",
            "width": width,
            "height": height
        }
    },
    "aliases": {
        "icon-alias": {
            "parent": "icon-name"
        }
    },
    "width": default width,
    "height": default height
}

"icons" object contains list of all icons.

Each icon has following properties:

  • body - icon body
  • width - width in pixels
  • height - height in pixels
  • rotate - rotation. Default = 0. Values: 0 = 0deg, 1 = 90deg, 2 = 180deg, 3 = 270deg
  • hFlip - horizontal flip. Boolean value, default = false
  • vFlip - vertical flip. Boolean value, default = false
  • hidden - If set to true, icon is hidden. That means icon was removed from collection for some reason, but it is kept in JSON file to prevent applications that rely on old icon from breaking

Width or height might be missing. If icon does not have width or height, use default width or height from root object. rotate, hFlip and vFlip are all optional.

Optional "aliases" object contains list of aliases for icons. Format is similar to "icons" object, with additional property "parent" that points to parent icon. Any other properties overwrite properties of parent icon.

For more information see developer documentation on https://iconify.design/docs/json-icon-format/

Extracting individual SVG icons

See JSON tools readme for instructions for PHP or Node.js.

const fs = require('fs');
const {SVG, Collection} = require('@iconify/json-tools');

let collection = new Collection();
collection.loadIconifyCollection('mdi');
collection.listIcons(true).forEach(icon => {
    let svg = new SVG(collection.getIconData(icon));
    fs.writeFileSync('mdi-' + icon + '.svg', svg.getSVG({
        height: 'auto'
    }));
});
use \Iconify\JSONTools\Collection;
use \Iconify\JSONTools\SVG;

$collection = new Collection();
$collection->loadIconifyCollection('mdi');
foreach ($collection->listIcons(true) as $icon) {
    $svg = new SVG($collection->getIconData($icon));
    file_put_contents('mdi-' . $icon . '.svg', $svg->getSVG([
        'height'    => 'auto'
    ]));
}

License

This is collection of works by various authors, not original collection.

See collections.md for list of collections and their licenses.