Back to Blog

Interactive shadcn/ui Components in MDX

March 20, 2024
10 min read
shadcn/uiMDXClient ComponentsInteractivity

Exploring interactive shadcn/ui components that require client-side rendering in MDX

Share this post

This post demonstrates how to use interactive shadcn/ui components that require client-side rendering in your MDX content. These components need to be rendered on the client side because they maintain state and handle user interactions.

Command

The Command component provides a command palette interface:

Accordion Component

The Accordion component is a great example of an interactive component that needs client-side rendering:

Dialog Components

Alert Dialog

The Alert Dialog component is used for destructive actions that require confirmation:

Dialog

The Dialog component is used for modal interactions:

Hover Card

Hover cards provide additional information on hover:

Form Components

Checkbox

Select

Switch

Popover

Sheet

Tabs

Account

Make changes to your account here. Click save when you're done.

Toggle

Additional Client-Side Components

The Carousel component provides a sliding interface for content:

1
2
3

Resizable

The Resizable component allows for resizable panels:

Sidebar
Content

Progress

The Progress component shows a loading indicator:

Code Snippet

The CodeSnippet component provides syntax highlighting:

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

Chart

The Chart component provides data visualization:

Image

The Image component provides optimized image loading:

Photo by Drew Beamer

Collapsible

The Collapsible component provides expandable/collapsible content:

Toast

The Toast component provides notifications:

Tooltip

The Tooltip component provides additional information on hover:

The NavigationMenu component provides a dropdown navigation interface:

Pagination

The Pagination component provides navigation between pages:

Radio Group

The RadioGroup component provides a set of radio buttons:

Slider

The Slider component provides a range input:

50%

Toggle Group

The ToggleGroup component provides a set of toggle buttons:

Aspect Ratio

The AspectRatio component maintains a consistent width/height ratio:

Photo by Drew Beamer

When to Use Client-Side Rendering

Use client-side rendering for MDX content when:

  1. You need interactive components that maintain state
  2. Components require user input or event handling
  3. You're using components that need to access browser APIs
  4. Components need to respond to user interactions in real-time

For static content or components that don't require interactivity, stick with server-side rendering for better performance.