node-icons
v1.0.1
Published
<!-- DO NOT REMOVE - contributor_list:data:start:["Borrus-sudo"]:end -->
Downloads
53
Readme
🍱 node-icons
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