Skip to content

How to Render Raw HTML with Inline Styles in MDX? #2609

Discussion options

You must be logged in to vote

The MDX compiler supports 2 languages: markdown and MDX.

The markdown language supports inline HTML. You can use rehype-raw to interpret this. The style attribute is a string. MDX compiles this to a prop with an object value when it compiles the markdown to JSX.

The MDX language supports JSX. The style prop is unprocessed.

React expects the style prop to be an object. It throws the error you’re seeing when it receives style as a string. MDX has nothing to do with this.

You can’t mix HTML and JSX. These syntaxes conflict with each other. Everything works as expected. There are no plans to change the current behaviour.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@salmanbukhari37
Comment options

@remcohaszing
Comment options

@salmanbukhari37
Comment options

@remcohaszing
Comment options

Answer selected by salmanbukhari37
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants