Creating compelling and dynamic content with MDX is powerful. But as you seamlessly integrate JSX components and dynamic data into your Markdown, it's crucial to ensure that your content is accessible to everyone. Building accessible MDX isn't just a good idea; it's essential for reaching a wider audience and providing an inclusive experience.
MDX allows for richer, more interactive content than standard Markdown. This power comes with responsibility. If not implemented with accessibility in mind, your interactive components, embedded data, and complex layouts can pose barriers for users with disabilities. Consider:
Integrating accessibility into your MDX workflow requires a conscious effort during content creation and component development. Here are some key best practices:
When embedding JSX components in your MDX, use semantic HTML elements whenever possible. Instead of using generic <div> elements for everything, opt for elements like <nav>, <article>, <aside>, <button>, <input>, etc. This helps assistive technologies understand the structure and meaning of your content.
// Instead of this (less semantic):
<div>
<button>Click me</button>
</div>
// Use this (more semantic):
<button>Click me</button>
All interactive elements within your MDX content, whether they are custom React components or standard HTML elements, must be fully navigable and usable with a keyboard. Test your content by tabbing through it to ensure all interactive elements receive focus and can be activated.
ARIA (Accessible Rich Internet Applications) attributes provide additional information to assistive technologies about the roles, states, and properties of UI elements. Use ARIA attributes strategically to enhance the accessibility of complex components or dynamic content. For example, you might use aria-label to provide a more descriptive name for a button or aria-hidden to hide decorative elements from screen readers.
If you embed images within your MDX, always provide descriptive alt text. This text is read by screen readers and displayed if the image fails to load. Be concise but informative about the content of the image.

Ensure that the text and background colors in your MDX content and embedded components have sufficient contrast. This is crucial for users with visual impairments. You can use online contrast checkers to verify your color choices meet accessibility standards.
If you're building a design system or library of reusable components for your MDX content, bake accessibility into their design from the start. This ensures that any content created using these components will inherit a baseline of accessibility.
The best way to understand how accessible your MDX content is is to test it with assistive technologies. Use a screen reader (like VoiceOver, JAWS, or NVDA) to navigate and interact with your content. You can also use keyboard-only navigation to identify any focus issues.
While .do currently focuses on compiling and managing MDX content, future developments may include features and Agents that can help you analyze and identify potential accessibility issues within your MDX files and embedded components. Stay tuned for updates!
MDX is a powerful format that lets you seamlessly write JSX in your Markdown documents. This enables you to embed interactive components, render dynamic data, and create richer content experiences.
import {compile} from '@mdx-js/esbuild'
let result = await compile('**Hello**, world!')
console.log(String(result))
.do provides Agents and APIs specifically designed for working with MDX. You can use them to compile MDX, extract data, transform content, and integrate MDX workflows into your applications and services.
You can integrate MDX into a variety of use cases, including technical documentation with live code examples, interactive blog posts, dynamic landing pages, and educational content with embedded applications.
Building accessible MDX content is an ongoing process. By following these best practices, you can create engaging, dynamic content that is usable and enjoyable for everyone. Prioritizing inclusion in your content creation process is not only the right thing to do, but it also expands your audience and improves the overall quality of your content. Start incorporating these accessibility principles into your MDX workflow today!