npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

material-icon-resolver

v0.1.4

Published

Resolve Material Icon Theme icon names, filenames, and CDN URLs from a file path, folder path, or language ID.

Readme

Material Icon Resolver

Resolve Material Icon Theme icon names, SVG filenames, and CDN URLs from file paths, folder paths, or VSCode language IDs.

Zero dependencies. ESM + CJS. Node, Bun, Deno, browser.

Install

npm install material-icon-resolver

Usage

import { resolveMaterialIcon } from "material-icon-resolver";

resolveMaterialIcon("src/index.ts");
// {
//   name: "typescript",
//   filename: "typescript.svg",
//   cdnUrl: "https://cdn.jsdelivr.net/npm/[email protected]/icons/typescript.svg",
//   type: "file",
//   source: "fileExtensions",
// }

resolveMaterialIcon("src", { type: "folder" });
// { name: "folder-src", filename: "folder-src.svg", ... }

resolveMaterialIcon("src", { type: "folder", open: true });
// { name: "folder-src", filename: "folder-src-open.svg", ... }

Resolve directly from a VSCode language ID — handy for editors like Monaco where the path may be synthetic:

import { resolveMaterialIconByLanguageId } from "material-icon-resolver";

resolveMaterialIconByLanguageId("rust");
// { name: "rust", filename: "rust.svg", ..., source: "languageIds" }

Or pass languageId as a fallback hint — used only when the path itself doesn't match anything specific:

resolveMaterialIcon("scratch.unknown-ext", { languageId: "rust" });
// → rust (path miss, languageId wins)

resolveMaterialIcon("package.json", { languageId: "rust" });
// → nodejs (specific filename match still wins)

Convenience helpers:

import { getMaterialIconName, getMaterialIconCdnUrl } from "material-icon-resolver";

getMaterialIconName("package.json");
// "nodejs"

getMaterialIconCdnUrl("package.json");
// "https://cdn.jsdelivr.net/npm/[email protected]/icons/nodejs.svg"

Split entries

The root entry bundles both file and folder lookups. Import from /file or /folder to load only one side:

import { resolveMaterialFileIcon } from "material-icon-resolver/file";
import { resolveMaterialFolderIcon } from "material-icon-resolver/folder";

resolveMaterialFileIcon("src/index.ts");
resolveMaterialFolderIcon("src", { open: true });

CommonJS works the same way:

const { resolveMaterialFileIcon } = require("material-icon-resolver/file");

API

resolveMaterialIcon(path, options?)

Resolve from a file or folder path. Returns ResolvedMaterialIcon, or null when fallback: "none" and no match is found.

type ResolvedMaterialIcon = {
  name: string;       // e.g. "typescript"
  filename: string;   // e.g. "typescript.svg"
  cdnUrl: string;
  type: "file" | "folder";
  source:
    | "fileNamesWithPath"
    | "fileNames"
    | "fileExtensions"
    | "languageIds"
    | "rootFolderNames"
    | "folderNames"
    | "default";
};

resolveMaterialIconByLanguageId(languageId, options?)

Resolve from a VSCode language ID (e.g. "typescript", "rust", "shellscript"). Returns a ResolvedMaterialIcon with type: "file", or null. Accepts cdn / version / baseUrl / fallback.

Split-entry variants

  • resolveMaterialFileIcon(path, options?) — accepts cdn / version / baseUrl / languageId / fallback: "file" | "none".
  • resolveMaterialFileIconByLanguageId(languageId, options?) — accepts cdn / version / baseUrl / fallback: "file" | "none".
  • resolveMaterialFolderIcon(path, options?) — accepts cdn / version / baseUrl / open / fallback: "folder" | "none".

Options

| Option | Type | Default | Description | | ------------ | ----------------------------------- | ---------------------------------------- | ----------- | | type | "file" \| "folder" | "file" | Resolve path as a file or folder. | | open | boolean | false | Append -open for expanded folder icons. | | languageId | string | — | VSCode language ID used as a fallback when path lookup misses. Ignored when type is "folder". | | fallback | "file" \| "folder" \| "none" | matches type | Returned when no match is found. "none" returns null. | | cdn | "jsdelivr" \| "unpkg" | "jsdelivr" | CDN provider for cdnUrl. | | version | string | pinned upstream version | material-icon-theme version on the CDN. | | baseUrl | string | — | Custom base URL. Overrides cdn and version. |

Resolution order

FilesfileNamesWithPath[parent/basename]fileNames[basename]fileExtensions[longest…shortest]languageIds[languageId] → fallback.

FoldersrootFolderNames[basename]folderNames[basename] → fallback. Folder maps include the upstream extendFolderNames aliases (name, .name, _name, -name, __name__).

All keys match case-insensitively.

Other exports

import {
  metadata,                     // { upstreamVersion, upstreamCommit, ... }
  buildCdnUrl,                  // ({ cdn, version, filename }) => string
  buildBaseUrl,                 // (baseUrl, filename) => string
  MATERIAL_ICON_THEME_PACKAGE,  // "material-icon-theme"
} from "material-icon-resolver";

License

MIT