MDX Deck uses Theme UI and Emotion for styling, making practically any part of the presentation themeable.
MDX Deck includes several built-in themes to change the look and feel of the presentation.
Export theme from your MDX file to enable a theme.
import { themes } from 'mdx-deck'
export const theme = themes.dark
# Dark ThemeView the Themes docs to see all available themes.
A custom theme can be provided by exporting theme from the MDX file.
import myTheme from './theme'
export const theme = myTheme
# HelloThemes are based on Theme UI and support customizing typography, color, layout, and other element styles.
// Example theme.js
export default {
fonts: {
body: 'Roboto, sans-serif',
monospace: '"Roboto Mono", monospace',
},
colors: {
text: 'white',
background: 'black',
primary: 'blue',
},
}To compose multiple themes together, merge the objects together into a single theme and export that theme from your deck.
Themes can specify a googleFont field to automatically add a <link> tag to the document head.
Alternatively, use the <Head /> component to add a custom <link> tag.
By default fenced code blocks do not include any syntax highlighting.
Themes can provide a set of custom MDX components, including a replacement for the default code component that can add syntax highlighting with libraries like react-syntax-highlighter.
MDX Deck includes two themes for adding syntax highlighting with react-syntax-highlighter: highlight and prism.
import { themes } from 'mdx-deck'
export const theme = {
...themes.prism
}Since MDX supports using React components inline, you can also import a syntax highlighting component directly, if you prefer.
import Highlighter from 'react-syntax-highlighter'
<Highlighter language='javascript'>
{`export const hello = 'hi'`}
</Highlighter>Add a theme.styles object to style specific markdown elements.
// example theme
export default {
styles: {
h1: {
textTransform: 'uppercase',
letterSpacing: '0.1em',
},
blockquote: {
fontStyle: 'italic',
},
}
}colors: object of colors used for MDX componentstext: root foreground colorbackground: root background colorprimary: primary color
fonts.body: base font familyfonts.heading: heading font familyfonts.monospace: font family for<pre>and<code>text.heading: styles for all headingsstyles: Theme UI styles for MDX elementsstyles.Slide: styles for the wrapping Slide componentstyles.Header: styles for the Header componentstyles.Footer: styles for the Footer componentcomponents: object of MDX componentsgoogleFont: Stylesheet URL for adding a Google Font