MDX Deck consists of several different packages. The core mdx-deck
package includes the CLI, @mdx-deck/components
,
@mdx-deck/themes
, and @mdx-deck/layouts
.
See the components docs for details.
MDXDeck
MDXDeckState
Head
Image
Notes
Steps
Appear
Slide
Zoom
Embed
See the layouts docs for details.
Invert
Split
SplitRight
FullScreenCode
Horizontal
See the themes & theming docs for details.
MDX Deck uses a stateful React context for each slide. Use the context APIs with caution as they are less stable than the end-user MDX Deck API.
metadata
(object) object for storing slide metadata such as speaker notes and step countstep
(number) the current step indexmode
(string) the current application modemodes
(object) object of application modesupdate
(function) updates application stateregister
(function) registers slide metadataindex
(number) the current slide indexgoto
(function) function to navigate to a specific slideprevious
(function) navigate to the previous slide or stepnext
(function) navigate to the next slide or step
The useSteps
hook can be used to register custom components that rely on steps, similar to the Appear component.
It takes one argument for the total length of steps and returns the current step state.
// example
import React from 'react'
import { useSteps } from '@mdx-deck/components'
export default props => {
const length = 4
const step = useSteps(length)
return (
<h2>
The current step is {step}/{length}
</h2>
)
}
The useDeck
component can be used to hook into MDX Deck state.
It returns the app context and can be used in a custom Provider component or other custom components.
// example custom Provider
import React from 'react'
import { useDeck } from '@mdx-deck/components'
export default props => {
const state = useDeck()
return (
<div>
{props.children}
<div
css={{
position: 'fixed',
right: 0,
bottom: 0,
margin: 16,
}}
>
Slide {state.index + 1}/{state.length}
</div>
</div>
)
}