Skip to main content

Iconify

Install @iconify/react and expose its Icon component through MDXComponents to use Iconify icons in MDX and React.

Expose the component through src/theme/MDXComponents.js or .tsx. Create the file if your project does not already have one.

Installing Iconify​

Iconify is available for React as a Node Package Manager (NPM) package. To install Iconify, run the following command:

npm install --save @iconify/react

Using Iconify with Markdown or MDX​

You can use Iconify in your Markdown or MDX files by exposing the Iconify component in MDXComponents. An example of this is below with added comments to aid understanding:

src/theme/MDXComponents.js
import React from 'react';
// Import the original mapper
import MDXComponents from '@theme-original/MDXComponents';
import { Icon } from '@iconify/react'; // Import the entire Iconify library.

export default {
// Re-use the default mapping
...MDXComponents,
IIcon: Icon, // Make the iconify Icon component available in MDX as <icon />.
};

We can then use the icon component in MDX files:

docs/my-doc.mdx
---
title: My Doc
---

<IIcon icon="mdi:github" height="48" /> This is a GitHub icon.

Use the Iconify Icon Explorer to search icon sets and find icon names.

Using Iconify with React​

In React components, render icons with Icon. See the Iconify React documentation for details.

If this is working you'll see an Iconify GitHub icon below: