mrkeyoor.comAsk

npm package

@mdi/js review

Use @mdi/js when your app owns the SVG renderer and you want named path imports.

npmInfraupdated 22 Nov 2026

An icon import can give you a string when you expected a component. @mdi/js 7.4.47 supplies Material Design Icons as SVG path data. Named exports such as mdiAccount hold the value for a path element's d attribute. Your code supplies the surrounding SVG, its size, color and accessible name. That makes the package useful when you already have an icon renderer, but it leaves real UI work to you.

Verdict

Use @mdi/js when your app owns the SVG renderer and you want named path imports. Start with one icon in your actual production build, then check the emitted code and the control's accessible name before adopting it across a screen.

Answers from our run

@mdi/js or @mdi/svg: which should you use?

@mdi/svg: Choose @mdi/svg when you need Material Design Icons as SVG assets rather than JavaScript path exports. Use @mdi/js when your app owns the SVG renderer and you want named path imports.

When should you not use @mdi/js?

You expect an imported icon to be a ready-made component. mdiAccount is a string, so rendering it as a component is the wrong interface.

API stability4/5The version-pinned implementation exports mdiAccount and mdiCheck as strings, and the matching README shows a named import. This is a small, inspectable data interface with little calling behavior to learn. The score rewards that narrow contract, not a tested upgrade history: renaming an imported symbol or changing artwork can still affect your application, and cross-version compatibility was not tested.
Docs3/5The version-matched README gives the install command, a named mdiAccount import, a tree-shaking note naming WebPack 4 and Rollup, and links to related distributions. It is enough to identify what an import returns. It does not walk through SVG sizing, accessible naming or a current bundler configuration, so a team building its first icon wrapper still needs separate platform knowledge.
Maintenance2/5This score rates verification visible in the published manifest, not maintainer responsiveness. Version 7.4.47 publishes build commands, but its test script prints Error: no test specified and exits with failure. That is a weak automated-test signal for this distribution. It does not establish that the upstream artwork is untested or abandoned, and no response-time or future-release claim follows from it.
Ecosystem3/5The published manifest supplies CommonJS, an ES module entry and TypeScript declarations, while the pinned README points readers to React, SVG and webfont distributions. That gives several documented integration routes. The score reflects packaging breadth with integration work left to the application. Download totals, framework compatibility and adoption are not used as evidence of runtime quality.

Use it if

Your app already has an SVG wrapper and needs Material Design Icons path data to feed it.
You want named imports that a production bundler can analyze, and you can inspect the resulting output before shipping.
Several UI layers need the same artwork without tying the path data to one framework.
You want to keep icon labels and button behavior in your own components.

Skip it if

You expect an imported icon to be a ready-made component. mdiAccount is a string, so rendering it as a component is the wrong interface.
You need complete SVG files to copy into an asset directory. Choose the SVG distribution instead of writing an export step.
Your existing site depends on a webfont and icon classes. Moving to path strings means changing its markup and rendering code.
You cannot check production bundle output. A runtime lookup across the entire imported namespace can defeat the small subset you intended to ship.

Setup reality

Install the reviewed version with npm install @mdi/js@7.4.47, then import the named paths your screen needs. The published manifest points main to commonjs/mdi.js, module to mdi.js and types to mdi.d.ts. It declares sideEffects: false. Those are packaging signals, not evidence that every build tool will remove unused paths. The pinned README names WebPack 4 and Rollup for tree shaking; check your own production build rather than treating that old statement as a guarantee for a current toolchain.

The annoying part starts after the import. A path string needs an SVG element with the right coordinate system. The version-matched account asset uses viewBox="0 0 24 24". Give the SVG explicit dimensions, set the path's fill if it should follow text color, and decide whether the picture conveys information. Hide decorative icons from assistive technology. For an icon-only button, put the action name on the button itself. A standalone meaningful graphic needs its own accessible name. These are application responsibilities, not features supplied by the path export.

Keep dynamic selection finite. Import the few icons a screen accepts and build a local map, with a fallback for unknown keys. Avoid importing the whole catalog just to look up a name received from an API. The examples below illustrate integration with native DOM APIs and CSS; they were checked against the published-version source but were not executed in a browser or installed in a test project. No install timing, accessibility result or application bundle measurement is claimed.

Ratings use a documentation-based scale: 1 means the inspected material leaves the relevant contract largely unspecified, 3 means it supports a usable approach with material gaps, and 5 means detailed guidance and verification cover the dimension. Intermediate scores reflect partial coverage. Maintenance here rates published verification signals, and ecosystem rates documented integration formats. Neither measures support response, adoption or future compatibility.

Patterns

Import path data by name import-path

import { mdiAccount } from '@mdi/js'
console.log(mdiAccount)

Documentation-based, unexecuted illustration. mdiAccount is SVG path data, not SVG markup or a component. Install 7.4.47 for the version reviewed here.

Create a decorative SVG with DOM APIs create-svg

import { mdiAccount } from '@mdi/js'

function decorativeIcon(data) {
  const ns = 'http://www.w3.org/2000/svg'
  const svg = document.createElementNS(ns, 'svg')
  svg.setAttribute('viewBox', '0 0 24 24')
  svg.setAttribute('width', '24')
  svg.setAttribute('height', '24')
  svg.setAttribute('aria-hidden', 'true')
  svg.setAttribute('focusable', 'false')
  const path = document.createElementNS(ns, 'path')
  path.setAttribute('d', data)
  path.setAttribute('fill', 'currentColor')
  svg.append(path)
  return svg
}

document.body.append(decorativeIcon(mdiAccount))

Unexecuted browser illustration. The account asset uses a 24 by 24 viewBox. The helper creates a decorative image, so adjacent text must carry any meaning.

Name a standalone graphic name-graphic

const profileGraphic = decorativeIcon(mdiAccount)
profileGraphic.removeAttribute('aria-hidden')
profileGraphic.setAttribute('role', 'img')
profileGraphic.setAttribute('aria-label', 'Account')
document.body.append(profileGraphic)

Uses decorativeIcon and mdiAccount from the earlier example. Removing aria-hidden matters before naming the graphic. This illustrates author-supplied labeling, not an accessibility test result.

Put the action name on the button label-button

const accountButton = document.createElement('button')
accountButton.type = 'button'
accountButton.setAttribute('aria-label', 'Open account settings')
accountButton.append(decorativeIcon(mdiAccount))
document.body.append(accountButton)

Uses the earlier helper and import. Keep the inner image decorative to avoid repeating its name. This snippet creates the control; your app still needs to attach its settings action.

Size the SVG without changing its coordinates size-icon

const icon = decorativeIcon(mdiAccount)
icon.classList.add('account-icon')
document.body.append(icon)

/* Put this rule in your stylesheet. */
/* .account-icon { width: 1.25rem; height: 1.25rem; } */

Uses the earlier helper and import. Keep viewBox at 0 0 24 24 for this artwork. CSS dimensions scale the viewport; changing viewBox instead can crop or reposition the drawing.

Let an icon follow text color inherit-color

const badge = document.createElement('span')
badge.style.color = '#2456a6'
badge.append(decorativeIcon(mdiAccount), ' Account')
document.body.append(badge)

Uses the earlier helper and import. Its path explicitly sets fill to currentColor. Setting CSS color without that fill policy does not express the same rendering intent.

Limit runtime lookup to known icons bound-lookup

import { mdiAccount, mdiCheck } from '@mdi/js'

const paths = new Map([
  ['account', mdiAccount],
  ['done', mdiCheck],
])

function pathFor(name) {
  return paths.get(name) ?? mdiAccount
}

console.log(pathFor('done'))

Unexecuted illustration. Both named exports exist in the pinned implementation. The map supplies a fallback and bounds the imported set, but it does not prove a particular emitted bundle size.

Keep the path boundary explicit in TypeScript type-path

import { mdiAccount } from '@mdi/js'

function iconPath(data: string): string {
  return data
}

const accountPath: string = iconPath(mdiAccount)

Unexecuted TypeScript illustration. The package advertises mdi.d.ts, and the implementation supplies a string. This local function is your application contract, not an API exported by @mdi/js.

Alternatives

PackageRegistryPick it when
@mdi/svgnpmChoose @mdi/svg when you need Material Design Icons as SVG assets rather than JavaScript path exports.
@mdi/fontnpmChoose @mdi/font when you need the Material Design Webfont collection for a font-based UI.

More infra guides

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.