Skip to content

theme-default

@vuepress/theme-default

The default theme of VuePress. It is a thin layout layer ported from the VitePress default theme: the theme provides the layout and the styles only (navbar, sidebar, doc outline, home page, footer and dark mode), while every other feature is delegated to the ecosystem plugins.

The former default theme

The theme that used to be published as @vuepress/theme-default is now @vuepress/theme-classic. The new default theme deliberately keeps the layout and the CSS variable names close to VitePress rather than to the classic theme, so the two themes are not drop-in replacements of each other — see Migrating from Classic when you move a site.

Usage

Install the theme:

npm i -D @vuepress/theme-default@next

Use it in your config:

.vuepress/config.ts
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  theme: defaultTheme({
    siteTitle: 'My Site',
    logo: '/logo.svg',
    nav: [{ text: 'Guide', link: '/guide/' }],
    sidebar: 'heading',
    appearance: true,
  }),
})

Every option of defaultTheme() is described in Config. The theme also accepts a hostname option, which is not part of the theme config itself but is required by the SEO and sitemap plugins:

export default defineUserConfig({
  theme: defaultTheme({
    hostname: 'https://example.com',
  }),
})

Page types

The theme registers a single Layout (plus NotFound for the 404 page) and decides what to render inside it from the page frontmatter type field. The default type is doc.

typeRenders
homeVPHome: hero, features, and the page content below them
doc (default)VPDoc: the article with its outline aside, last updated time and prev/next footer
pageVPPage: the markdown content only, without the doc aside and footer
contentThe raw markdown content only, without any layout shell
any custom layoutThe layout registered under that name in a client config

See Frontmatter for the fields each page type accepts, and Extending for custom layouts.

Where things are configured

ConcernConfigured withPage
Navbar, sidebar, outline, edit link, footer, theme UIdefaultTheme() optionsConfig
Page type, home page hero and features, per-page UIPage frontmatterFrontmatter
Bundled plugins and their switchesthemePluginsPlugins
UI texts and per-language optionslocalesLocale
Exported components, team and sponsor sectionsClient APIBuilt-in Components
Markdown syntaxBundled pluginsMarkdown
CSS variables, user stylesPlain CSSStyles
Custom layouts and layout slots.vuepress/client.tsExtending
Migration from the classic theme—Migrating from Classic

Wired plugins

The theme wires the following plugins automatically. Each of them can be disabled with false or configured with an options object through themePlugins; see Plugins.

PluginthemePlugins keyDefault
@vuepress/plugin-theme-data—Always enabled
@vuepress/plugin-copy-codecopyCodeEnabled
@vuepress/plugin-gitgitEnabled
@vuepress/plugin-shikishikiEnabled, github-light/github-dark
@vuepress/plugin-markdown-hintmarkdownHintEnabled, hint and alert
@vuepress/plugin-markdown-tabmarkdownTabEnabled, codeTabs
@vuepress/plugin-markdown-extmarkdownExtEnabled, vPre
@vuepress/plugin-markdown-rawmarkdownRawEnabled, style isolation on
@vuepress/plugin-active-header-linksactiveHeaderLinksEnabled
@vuepress/plugin-iconiconEnabled, assets: 'iconify'
@vuepress/plugin-medium-zoommediumZoomEnabled
@vuepress/plugin-nprogressnprogressEnabled
@vuepress/plugin-back-to-topbackToTopEnabled
@vuepress/plugin-links-checklinksCheckEnabled
@vuepress/plugin-seoseoOnly with hostname
@vuepress/plugin-sitemapsitemapOnly with hostname

Search is not bundled

A theme cannot choose a search backend for a site, so search is not part of the theme. Install @vuepress/plugin-slimsearch (local search) or @vuepress/plugin-docsearch (Algolia) and register it in plugins; the navbar renders the globally registered SearchBox component automatically.

Client API

The node entry (@vuepress/theme-default) exports defaultTheme together with the types describing the theme: ThemeOptions, ThemeConfig, ThemeLayout, ThemePageData, ThemePluginsOptions, ThemeContributor, AppearanceOptions and the DefaultTheme namespace (nav items, sidebar items, hero and feature options, footer, team members, and so on).

The client entry (@vuepress/theme-default/client) exports the built-in components and composables. Importing it also loads the theme styles and the Inter webfont.

Components: VPBadge, VPButton, VPDocAsideSponsors, VPDocFooterContributors, VPFeatures, VPHomeContent, VPHomeFeatures, VPHomeHero, VPHomeSponsors, VPImage, VPLink, VPNavBarSearch, VPSocialLink, VPSocialLinks, VPSponsors, VPTeamMembers, VPTeamPage, VPTeamPageSection, VPTeamPageTitle, VPThemeIcon.

Composables and helpers: useContributors, useLayout, usePageIsNotFound, usePageLastUpdated, usePageRelativePath, usePageType, useThemeData, useThemeLocaleData, useThemePageData, useThemePageFrontmatter, useThemeLocalePath, useThemeLocales, useRuntimeBase, useDarkMode, createDarkModeRef, themeDarkModeSymbol, COLOR_MODE_STORAGE_KEY.

See Built-in Components for the component props and Extending for the layout state returned by useLayout.

Next

MIT Licensed