Skip to main content

Theme API

VitePress themes are defined using a standard interface and can extend the default theme or create completely custom layouts.

Theme Interface

Theme Object

A VitePress theme is defined as an object with the following interface:
Component
The root layout component for your theme
(ctx: EnhanceAppContext) => Awaitable<void>
Function to enhance the Vue app instance
Theme
Another theme to extend from
() => void
Theme-level setup function (deprecated - use Layout component setup instead)
Component
Custom 404 component (deprecated - check useData().page.value.isNotFound in Layout)

EnhanceAppContext

The context object passed to enhanceApp:
Example Usage:

Default Theme

The default theme can be imported from vitepress/theme.

Importing the Default Theme

Without Fonts

Import the default theme without Inter font:

Default Theme Components

The default theme exports several components you can use in your custom theme or markdown:

Layout Components

VPBadge

Display a badge with different styles.
'info' | 'tip' | 'warning' | 'danger'
default:"tip"
Badge color theme
string
Badge text content
In Markdown:

VPButton

Stylized button component.
'brand' | 'alt' | 'sponsor'
Button style theme
string
Button text
string
Link URL
'small' | 'medium' | 'big'
default:"medium"
Button size

VPImage

Responsive image component with light/dark mode support.
string | { light: string, dark: string }
required
Image source URL or theme-specific URLs
string
required
Alternative text for the image

Home Page Components

VPHomeHero

Hero section for home pages.
Reads hero configuration from page frontmatter:

VPHomeFeatures

Features grid for home pages.
Reads features from page frontmatter:

VPHomeContent

Wrapper for custom home page content.

VPHomeSponsors

Display sponsors on the home page.

Team Components

VPTeamPage

Wrapper component for team pages.

VPTeamPageTitle

Title section for team pages.

VPTeamPageSection

Section wrapper for grouping team members.

VPTeamMembers

Display team member cards.
TeamMember[]
required
Array of team member objects
'small' | 'medium'
default:"medium"
Size of member cards
TeamMember Type:

Social Components

Display a group of social media links.

Single social media link icon.
string | { svg: string }
required
Icon name or custom SVG
URL to link to
string
Accessibility label
Built-in Icons:
  • discord
  • facebook
  • github
  • instagram
  • linkedin
  • mastodon
  • slack
  • twitter
  • youtube
  • x
Custom SVG:

Other Components

VPSponsors

Display sponsor logos in a grid.

VPDocAsideSponsors

Sponsors section for the aside/sidebar.
Reads sponsors from theme config carbonAds or sidebar.sponsors.

VPFeatures

Alternative features component.

Default Theme Composables

useLayout

Access layout state and computed properties.
ComputedRef<boolean>
Whether the current page is the home page
Ref<SidebarItem[]>
Current sidebar items
ComputedRef<SidebarItem[]>
Grouped sidebar items
ComputedRef<boolean>
Whether sidebar should be displayed
ComputedRef<boolean>
Whether sidebar is enabled at current viewport
ComputedRef<boolean>
Whether aside/outline should be displayed
ComputedRef<boolean>
Whether aside is positioned on the left
Ref<OutlineItem[]>
Page outline/headers
ComputedRef<boolean>
Whether local navigation should be shown

Custom Theme Example


Layout Slots

The default theme Layout component provides numerous slots for customization. See the Layout Slots documentation for a complete list.