Skip to content

MDX slides

A deck is one MDX file, deck.mdx. MDX is Markdown that can hold JSX, so everything Markdown does works, and any component the engine ships, or that you write, can sit between paragraphs.

---
title: My talk
theme: minimal
---
# The first slide
---
## The second slide, one column to the right
----
### A vertical slide, below the second
  • --- starts a new slide, one column to the right.
  • ---- starts a vertical slide beneath the previous one, making a stack: detail a talk can skip. → walks a slide’s steps and then moves to the next column; ↓/↑ move within a stack, and Space walks every slide in order.

The YAML block at the very top is the headmatter: deck settings (title, author, theme, transition, slideNumber, defaultTiming, …) and, at the same time, the frontmatter of the first slide. deck.config.ts overrides the headmatter, which overrides the defaults; every option is in the configuration reference.

YAML between two --- separators is that slide’s frontmatter:

---
layout: two-cols
background: aurora
transition: fade
class: hero
---

From the second slide on, a yaml code block as the very first thing in a slide is its frontmatter too. Editors highlight it as YAML, and it reads well in a long deck:

---
```yaml
layout: center
class: text-center
```
# A centred slide

A yaml block with a title or highlights (```yaml [config.yml]) is code to show, not frontmatter.

defaults in the headmatter is frontmatter every slide gets unless it sets the key itself:

---
title: My talk
defaults:
layout: center
transition: fade
---

A theme can bring defaults of its own; the deck’s sit on top of the theme’s, and a slide’s own keys win over both.

The keys you will use most:

Key Meaning
layout the slide’s layout; the first slide defaults to cover, the rest to default
class CSS classes on the slide (a string or a list)
id a stable name: #/results links to it, and <Link to="results"> finds it
background a colour, a gradient, an image, a video, a page, or a background component. See Themes and backgrounds
transition this slide’s transition
colorScheme dark or light: force tokens on this slide (a dark background under a light theme)
clicks the slide’s total steps, when it can’t be counted from its content
hide leave the slide out of the deck
timing seconds this slide should take, for the pacing timer
title, level the title and heading level the table of contents and the PDF’s bookmarks use (default: the first heading)

Every key, with its type, is in Configuration, and npx kadal-deck info slidepnpm exec kadal-deck info slideyarn kadal-deck info slidebunx kadal-deck info slide prints the same list.

A slide whose frontmatter has src: and nothing else is replaced by the slides of that file:

---
src: ./parts/intro.mdx
---
---
src: ./parts/results.mdx#2-5
---

#2-5 takes only those slides (1-based); #1,3,5-7 and #4- (to the end) work too. Any other key on the including slide merges into the first included slide, so layout: or class: there restyles it. An include that points at itself, directly or through another file, is reported, not followed.

layout: picks how a slide is arranged: cover, section, two-cols, image-right, fact and fourteen more, and a theme can add its own. Layouts with several regions take slots: a line ::right:: starts the slot called right.

---
layout: two-cols
---
# Left column
::right::
# Right column

Layouts and slots has every layout, its slots and the keys it reads, and how to register a layout of your own.

<Notes>Start with the poll. [click] Then reveal the first point. [click] And the second.</Notes>

An HTML comment at the very end of a slide is its notes too:

# The plan
<Click>First</Click>
<!--
Start with the poll.
[click] Then reveal the first point.
-->

Only comments at the end are notes; any other <!-- … --> is dropped. Both kinds can sit on one slide and are joined. For a comment that is only a comment, write {/* … */}.

The presenter view splits notes at [click]: segment N is highlighted exactly when the slide is at step N, so the notes keep pace with your clicks. [click:3] starts the part for step 3 exactly, and each marker is a button that jumps to its step. Notes are compiled to their own module and never load on the audience’s screens unless you share them; kadal-deck build --without-notes leaves them out of the build altogether.

notesAutoRuby in the headmatter annotates words in the notes with their reading, for a talk in a language you read less well:

notesAutoRuby:
日本語: ni hon go
勉強: べんきょう

A <style> block in a slide styles that slide only:

# This heading is red
<style>
h1 { color: crimson; }
:scope { background: #fff7ed; }
html.dark h1 { color: salmon; }
</style>

:scope (or &) is the slide itself, and html.dark … still means the dark scheme. The CSS follows the slide wherever it is drawn: the stage, the presenter’s previews, the overview, print and export. <style global> applies to the whole deck instead.

Anything exported from src/components.tsx is available in deck.mdx without an import:

src/components.tsx
export const components = {
Price: ({ amount }: { amount: number }) => <strong className="price">${amount}</strong>,
};
It costs <Price amount={4} /> a month.

Cards that share a row share a height: a <Glass> or <Callout> that is the only thing in its <Col> fills the cell, unless the row says align="start". Give your own card component the deck-card class to join in.

A component can tell when its slide becomes the current one: useSlideEnter(fn) and useSlideLeave(fn) (also exported as onSlideEnter and onSlideLeave) run then, never for a preview, the overview or print, and an enter can return a cleanup. useIsSlideActive() and useNavDirection() ("forward" or "backward") read the same state, and useClicks() the slide’s click step.

Every built-in component works without an import. The component reference lists each one with its props and an example; npx kadal-deck info components <Name>pnpm exec kadal-deck info components <Name>yarn kadal-deck info components <Name>bunx kadal-deck info components <Name> prints the same in a terminal.

Group Components
Layout Cols/Col, Grid, Center, Spacer, Stack, Stretch, Frame, Absolute, Transform, FitText, Drag, DragArrow
Clicks Click, After, Clicks, Switch/Case, ClickCount, Fragment
Content Callout (kind="info" | "tip" | "warn" | "danger" | "note"), Badge, Kbd, Mark, Arrow, Toc, Qr, Link, Notes, Counter, Typewriter, Encrypted, Confetti, Timer, Tex/Math
Context LightOrDark, RenderWhen, SlideCurrentNo, SlidesTotal, TitleRenderer
Media Image (with preview to enlarge), Video, Audio, Youtube, Tweet, BlueSky, Iframe
Code CodeGroup, MagicMove (usually written as fences: see Code)
Diagrams Mermaid, Sketch, KatexLines (see Maths, diagrams and sketches)
Motion Motion
Decoration GradientText, Glass, Glow, Chip, Icon (Lucide or any Iconify icon), Divider, Ribbon, Halo, Shimmer, Blob, Tilt
Backgrounds Background (see Themes and backgrounds)
Live QrJoin, Presence, Reactions, Poll, WordCloud, Quiz, Leaderboard, Questions, Pace (see The live room)
Glossary Term, Terms, TermReadout (see Glossary term cards)

Decoration components read the theme’s tokens and take a tone: accent, accent-2, good, warn, bad, info, neutral, purple, pink, amber, teal.

Want :badge[New] inline and ::callout blocks instead of JSX? Turn on Comark syntax.

layout: iframe* and <Iframe> load a page when its slide shows and unload it when you leave. A “click to interact” shield keeps your keys driving the deck until you mean to use the page; Done hands the keyboard back. The next slide’s pages are already loading, hidden, so arriving there looks instant. <Iframe scale={0.5}> renders a page at twice the pane and shrinks it: a desktop layout in a small card.

The stage is authored at 1920 × 1080 (width/height) and scaled uniformly to every window: edge to edge on a 16:9 screen, centred between bars on a phone, a tall window or a 4:3 projector, never reflowed. A slide whose content overflows is scaled down to fit (autoFit, on by default).

Send feedback