Extending Themes
If you'd like to customise an existing theme,
you can define a custom theme that extends it.
The custom theme's Layout
should render the original theme's Layout
component,
but apart from that you can treat it as a regular theme.
The theme used for these docs extends the default theme to add OpenGraph tags!
Creating Extended Themes
These examples will extend the default theme as an example.
Define a custom theme with defineTheme
and provide the original theme's definition to extends
:
Add a Layout
file inside the componentsPath
folder that renders the original theme's Layout
:
Extending the Default Theme
The default theme provides multiple methods of customisation, which we'd recommend configuring with a custom theme that extends it.
Customising CSS
The default theme's CSS can be customised using CSS variables:
The full list of overridable CSS variables is in the default theme's source code.
Using Different Fonts
The default theme uses a few fonts:
- Lexend for headings
- Inter for text
- JetBrains Mono for code
To stop these fonts from being loaded, set themeConfig.fonts
to false
:
You can then provide your own fonts:
Overriding Components
In addition to using a custom mdx-components
file to override the components available in markdown files,
the components listed here
can be overriden using ComponentsProvider
.
Most of these components are used as part of the layout, rather than inside your markdown files.
Last updated: 11/15/24, 4:03 AM