Skip to main content

Extending the Default Theme

The VitePress default theme is highly customizable through CSS variables, component registration, and layout slots. This allows you to build on top of the default theme without creating a theme from scratch.
Before proceeding, make sure you understand how custom themes work.

Basic Setup

Theme Entry File

Create .vitepress/theme/index.js or .vitepress/theme/index.ts:

Customizing CSS

CSS Variables

The default theme uses CSS custom properties for styling. Override them to customize colors, fonts, spacing, and more.
.vitepress/theme/custom.css
See the full list of CSS variables in the VitePress source code.

Custom Styles

Add custom CSS rules:
.vitepress/theme/custom.css

Using Custom Fonts

Web Fonts

By default, VitePress includes Inter font. To use different fonts:
.vitepress/theme/index.js
.vitepress/theme/fonts.css
Import from vitepress/theme-without-fonts to avoid bundling the default Inter font.

Local Fonts

.vitepress/theme/fonts.css
Preload the font:
.vitepress/config.ts

Registering Components

Global Components

.vitepress/theme/index.js

Layout Slots

The default theme provides layout slots to inject custom content at specific locations.

Available Slots

When layout: 'doc' (default):
  • doc-top - Before doc content
  • doc-bottom - After doc content
  • doc-footer-before - Before doc footer
  • doc-before - Before doc container
  • doc-after - After doc container
  • sidebar-nav-before - Before sidebar nav
  • sidebar-nav-after - After sidebar nav
  • aside-top - Top of aside
  • aside-bottom - Bottom of aside
  • aside-outline-before - Before outline
  • aside-outline-after - After outline
  • aside-ads-before - Before ads
  • aside-ads-after - After ads

Using Slots with Components

.vitepress/theme/index.js
.vitepress/theme/MyLayout.vue

Slot Examples

Add Banner to All Docs

.vitepress/theme/MyLayout.vue

Add Contributors List

.vitepress/theme/MyLayout.vue
.vitepress/theme/MyLayout.vue

Overriding Components

Replace default theme components using Vite aliases:
.vitepress/config.ts
Component names may change between minor releases. Check the source code for current names.

View Transitions

On Appearance Toggle

Add smooth transitions when toggling dark mode:
.vitepress/theme/Layout.vue

Complete Example

.vitepress/theme/index.js

Next Steps

Theme Configuration

Configure default theme options

Custom Theme

Create a completely custom theme