Back to Blog

Using shadcn/ui Components in MDX

May 15, 2025
2 min read
shadcn/uiMDXStyling

How to use shadcn/ui components directly in your MDX blog posts

Share this post

One of the great benefits of using MDX for your blog posts is the ability to include React components directly in your markdown. With our setup, you can use shadcn/ui components right in your blog posts!

Basic Usage

The standard markdown syntax works as expected:

Tables with shadcn/ui

Tables are automatically styled using shadcn/ui's Table component:

NameRoleDepartment
John DoeDeveloperEngineering
Jane SmithDesignerDesign
Bob JohnsonManagerAdministration

Using Alert Components

You can use the Alert component directly in your MDX:

Cards for Highlighted Content

Use Card components to highlight important information:

This content is displayed in a shadcn/ui Card component, making it stand out from the rest of your blog post.

Badges for Categories or Tags

You can use Badge components inline:

This post is about shadcn/ui and MDX.

Code Blocks

Code blocks are styled with proper syntax highlighting:

1function Welcome() {
2  return <h1>Hello, world!</h1>;
3}
js

You can also show function components with props:

1function Greeting({ name }) {
2  return <h1>Hello, {name}!</h1>;
3}
js

Benefits of Using shadcn/ui in MDX

  1. Consistent Design: Your blog posts match the rest of your website
  2. Interactive Components: Add interactive elements to your content
  3. Customizable: Easily customize the appearance of your components
  4. Accessibility: shadcn/ui components are built with accessibility in mind

Try adding some shadcn/ui components to your next blog post!