--- title: 'MDX Format' --- `MDX` is the syntax [Storybook Docs](../writing-docs/introduction.md) uses to capture long-form Markdown documentation and stories in one file. You can also write pure documentation pages in `MDX` and add them to Storybook alongside your stories. [Read the announcement](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) to learn more about how and why it came to be. ## Basic example Let's get started with an example that combines Markdown with a single story: ```md import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks'; import { Checkbox } from './Checkbox'; # Checkbox With `MDX` we can define a story for `Checkbox` right in the middle of our Markdown documentation. ``` And here's how that's rendered in Storybook:  As you can see there's a lot going on here. We're writing Markdown, we're writing JSX, and somehow we're also defining Storybook stories that are drop-in compatible with the entire Storybook ecosystem. Let's break it down. ## MDX-Flavored CSF [MDX](https://mdxjs.com/) is a standard file format that combines Markdown with JSX. This means you can use Markdown’s terse syntax (such as `# heading`) for your documentation, and freely embed JSX component blocks at any point in the file. MDX-flavored [Component Story Format (CSF)](https://medium.com/storybookjs/component-story-format-66f4c32366df) includes a collection of components called **"Doc Blocks"**, that allow Storybook to translate MDX files into storybook stories. MDX-defined stories are identical to regular Storybook stories, so they can be used with Storybook's entire ecosystem of addons and view layers. For example, here's the story from `Checkbox` example above, rewritten in CSF: ```js import React from 'react'; import { Checkbox } from './Checkbox'; export default { title: "MDX/Checkbox" component: Checkbox }; export const allCheckboxes = () => (
); ``` There's a one-to-one mapping from the code in `MDX` to `CSF`, which in turn directly corresponds to Storybook's internal `storiesOf` API. As a user, this means your existing Storybook knowledge should translate between the three. And technically, this means that the transformations that happen under the hood are simple and predictable. ## Writing stories Now let's look at a more realistic example to see a few more things we can do: ```js import { Meta, Story, Preview } from '@storybook/addon-docs/blocks'; import { Badge } from './Badge'; import { Icon } from './Icon'; # Badge Let's define a story for our `Badge` component: