Mochi Icons
DOCS · 06 / 07

Direct imports

Import one icon from its own file path.

Two ways to import

You can import an icon from its own file, or from the main package.

DIRECT IMPORT (RECOMMENDED)
import { CameraIcon } from "mochi-icons/CameraIcon";
MAIN PACKAGE
import { CameraIcon, BellIcon } from "mochi-icons";

Both give you the same icon. A direct import loads only that one file, so it is always the smallest. It also keeps your dev server fast, because it doesn't load the whole set.

How the path works

The path is the package name, a slash, and the component name. The name is the same in the path and in the curly braces.

ICONIMPORT
cameraimport { CameraIcon } from "mochi-icons/CameraIcon";
shopping-cartimport { ShoppingCartIcon } from "mochi-icons/ShoppingCartIcon";
volume-upimport { VolumeUpIcon } from "mochi-icons/VolumeUpIcon";

Other entry points

PATHWHAT'S IN IT
mochi-iconsEvery icon, plus the IconProps type.
mochi-icons/<Name>IconOne icon.
mochi-icons/metadataThe list of all icons (names, files, kinds). Only load this if you build an icon picker.

"Cannot find module" error

If TypeScript can't find a direct import, check these in order:

  1. Spelling and capitals. CameraIcon works, cameraIcon does not.
  2. Your TypeScript settings. In tsconfig.json, set moduleResolution to "bundler" (or "node16"). The old "node" setting can't see per-icon paths.
TSCONFIG.JSON
{
  "compilerOptions": {
    "moduleResolution": "bundler"
  }
}