The Power of MDX
One of MDX's killer features is the ability to mix markdown with React components. You write prose naturally, then drop in interactive elements wherever you need them.
A Live Counter
This isn't a static image or a screenshot. It's a real React component with useState:
Interactive Counter
Click the buttons. The state persists as you scroll. This is actual JavaScript running in your blog post.
Mix and Match
You can have normal markdown around components. Here's a list:
- Regular markdown list item
- Another item
- These are just markdown
And then immediately drop into something interactive:
Drag the sliders. The preview updates in real-time. The hex code is computed on the fly.
Custom Callouts
Components don't have to be complex. Here's a simple Callout component:
This is an info callout. Useful for additional context.
Pro tip: You can create any component you want and use it across all your posts.
Be careful not to over-engineer. Simple markdown is often enough.
How It Works
Components are registered in mdx-content.tsx:
const components = {
Callout,
ColorMixer,
Counter,
}Then you just use them like HTML tags in your MDX. No imports needed in the post itself.
When to Use This
Use interactive components when:
- Static content isn't enough â visualizations, calculators, live demos
- You want consistency â callouts, code playgrounds, styled elements
- Teaching concepts â let readers experiment, not just read
For everything else? Just write markdown. Don't overcomplicate.