DEV Community

Cover image for Learning MDX Deck: Getting Started
Dave Follett
Dave Follett

Posted on โ€ข Originally published at davefollett.io on

8 5

Learning MDX Deck: Getting Started

๐Ÿ™‹ What is MDX Deck?

MDX Deck was created by Brent Jackson (@jxnblk) and is a tool for creating presentation deck websites using MDX. MDX provides the ability to use Reactโ€™s JSX inside Markdown. The combination creates a powerful experience for building a web-based presentation deck. Here are a list of features, as listed on the MDX Deck GitHub Page:

  • ๐Ÿ“ Write presentations in markdown
  • โš› Import and use React components
  • ๐Ÿ’… Customizable themes and components
  • 0๏ธโƒฃ Zero-config CLI
  • ๐Ÿ’โ€โ™€๏ธ Presenter mode๏ฟผ
  • ๐Ÿ““ Speaker notes

๐Ÿ—๏ธ Installation

First make sure you have node installed and paste the following as package.json into a new file. Alternatively, you can run: npm init to generate a package.json file.

{
"name": "demo-mdx-deck",
"version": "1.0.0",
"description": "Demo MDX Deck",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
  },
"author": "Dave Follett",
"license": "MIT"
}
Enter fullscreen mode Exit fullscreen mode

Next, install mdx-deck with the following command.

npm i -D mdx-deck
Enter fullscreen mode Exit fullscreen mode

๐Ÿƒโ€โ™€๏ธ Getting Started

To create a simple presentation, create a file named deck.mdx and copy the following contents into it.

# SLIDE 1 - LIST

* I am a bullet list item
* I am another bullet list item
* I am another bullet list item

---

# SLIDE 2 - HEADERS

## Header 2
### Header 3
#### Header 4
##### Header 5

---

# SLIDE 3 - TABLE

| Fruit         | Weight   | Cost  |
| ------------- | ---------| ----- |
| Strawberries  | 16oz     | $3.99 |
| Blueberries   | 8oz      | $2.99 |
| Grapes        | 12oz     | $3.75 |
Enter fullscreen mode Exit fullscreen mode

Each slide is separated by ---. To see the presentation in action, add the following to the scripts section of package.json.

"scripts": {
  "start": "mdx-deck deck.mdx"
}
Enter fullscreen mode Exit fullscreen mode

And run the following command to start the development server.

npm start
Enter fullscreen mode Exit fullscreen mode

The presentation can be viewed at http://localhost:8080/.

Animation of the MDX Deck example

โŒจ๏ธ Keyboard Shortcuts

The following keyboard shortcuts can be used to interact with the presentation.

Key Description
Left Arrow Go to previous slide (or step in Appear)
Right Arrow Go to next slide (or step in Appear)
Space Go to next slide (or step in Appear)
Alt + P Toggle Presenter Mode
Alt + O Toggle Overview Mode
Alt + G Toggle Grid Mode

๐Ÿ Conclusion

As you can see, you can get up and running with MDX Deck pretty quickly. There is a lot more to MDX Deck than I have shown here. Coming up ๐Ÿ”œ, I will be exploring more of the features it provides, such as, importing react components, layouts, themes, speaker notes, and deploying to Netlify.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (2)

Collapse
 
thejoezack profile image
Joe Zack โ€ข

Finally got my head around this, really really cool! I'd love to re-use react components in my slides.

Collapse
 
davefollett profile image
Dave Follett โ€ข

Thanks Joe. I recently learned that MDX can be used with Gatsby too. Maybe it could help with some of the sites you are building.

mdxjs.com/getting-started/gatsby/

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs