#How to import icon from HeroIcons in mdx doc file ?

1 messages · Page 1 of 1 (latest)

worn viper
#

Trying to import heroicon in mdx doc file using the IconGallery.

Getting the following error:


Check the render method of `MDXContent`.```

This is my mdx file:

```import { Meta, Title, IconGallery, IconItem } from '@storybook/blocks'

import { UserCircle } from '@heroicons/react/24/outline'

<Meta title="Iconography" />

# Iconography

<IconGallery>
  <IconItem name="user">
    <UserCircle />
  </IconItem>
</IconGallery>
cedar spruce
#

Does it work outside of the IconGallery component?

worn viper
#

Hi @cedar spruce no! :/

#

I'm importing the icon the same way I'm importing it to the next.js project, should that work or am I doing it the wrong way ?

cedar spruce
#

I think that should work, but I don't know the first thing about heroicons 😅 .

For testing purposes, have you tried importing those icons into a story and rendering that. Just to see if the import is correct in the context of Storybook.

worn viper
#

Yea they work fine in the stories for my components that uses heroicons.

#

Not sure why it fails in the mdx file...

#

Here is a working story

cedar spruce
#

That's super strange, I don't see anything out of the obvious with the way you imported a component into the MDX file. We use MDX2 under the hood, and I'm looking at the docs here https://mdxjs.com/docs/using-mdx/#components

Maybe @wind meadow would know more about the nuances of this?

MDX

This article explains how to use MDX files in your project. It shows how you can pass props and how to import, define, or pass components.

worn viper
#

hmm 🤔

#

I tried with lucide-react icons and that's working fine actually!