Borrus-sudo / node-icons

🍱 Simple nodejs support for using icons!

Home Page:https://www.npmjs.com/package/node-icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🍱 node-icons

All Contributors License Last Commit Stars Forks

Usage

Checkout its unit tests to see complete usage with output!

import Icons from "node-icons";
const icons = Icons({
  // auto installs the collection set of an icon if not already installed
  installPkg: true,
  alias: new Map(),
  prefix: "lucide",
  separator: ":",
});
const result = await icons.iconify("This is cool right! ::activity::", {
  // The `styles` object's key value pair are appended as attributes to the svg
  styles: {
    width: 100,
    color: `"red"`, // it is important to have quotes for those values which need them like color="red"
  },
  base64: false,
});

The Icon({}) function expects an object of type config. The object returned by it has 2 methods

type returnVal = {
  getIcons(iconName: any, styles: any, base64: boolean): Promise<string>;
  getIconsSync(iconName: any, styles: any, base64: boolean): string;
  iconify(
    text: string,
    options: {
      styles: object;
      base64: boolean;
    },
    regex?: RegExp,
  ): Promise<string>;
};

With getIconsSync, auto installing icons is not possible.

Installation

npm i node-icons or yarn add node-icons to install.

npm i @iconify/json to install all icons or npm i @iconify-json/<collection-id> to install a specific icon set.

πŸŽ‰ Contributing

Contributions are welcome! Whether it is a small documentation change or a breaking feature, we welcome it!

Please note: All contributions are taken under the MIT license

πŸ‘₯ Contributors

About

🍱 Simple nodejs support for using icons!

https://www.npmjs.com/package/node-icons

License:MIT License


Languages

Language:TypeScript 94.3%Language:JavaScript 4.2%Language:Shell 1.5%