Skip to content

Built-in Components

The theme exports its building blocks, so a custom layout or a home page can be composed from them without copying the theme. Document them all in a table first, then give per-component props. Keep references to our own pages internal.

@vuepress/theme-default

The components are exported by the client entry. Import the ones a page uses in a <script setup> block:

<script setup>
import { VPButton, VPImage } from '@vuepress/theme-default/client'
</script>

Two components are registered globally, so they work in markdown without an import:

  • Badge — the VPBadge component, which keeps the <Badge text="..." type="..." /> syntax of @vuepress/theme-classic.
  • VPIcon — registered by @vuepress/plugin-icon, which renders the icon names used by the navbar, the sidebar and the feature cards.

Overview

ComponentRenders
VPHomeHeroThe hero of a home page, from its hero frontmatter
VPHomeFeaturesThe feature cards of a home page, from its features frontmatter
VPHomeContentA full-width container for the markdown content of a home page
VPHomeSponsorsA sponsor section of a home page
VPFeaturesA grid of feature cards, from a prop
VPTeamPageThe container of a team page
VPTeamPageTitleThe title block of a team page
VPTeamPageSectionA section of a team page
VPTeamMembersA grid of team members
VPSponsorsA sponsor section, with tiers
VPDocAsideSponsorsA sponsor grid for the aside of a document page
VPButtonA themed link or button
VPBadgeA small badge, also registered as Badge
VPImageAn image with a light and a dark source
VPLinkA link with the external-link handling of the theme
VPSocialLinksA row of social links
VPNavBarSearchThe search placeholder of the navbar
VPThemeIconAn icon from @vuepress/plugin-icon or a theme icon class
VPDocFooterContributorsThe contributors line of the document footer

Every component is also exported with its types from @vuepress/theme-default/client.

Home Components

These components read the home page frontmatter themselves, so the home page content usually composes them without props:

---
type: home
hero:
  name: Theme Default
  text: The default theme of VuePress
features:
  - title: A thin layout layer
    details: The layout of VitePress, with the plugin system of VuePress.
---

The markdown below the hero and the features.

VPHomeHero

Renders the hero from the hero frontmatter. It has no props; the slots are the ones of the hero: home-hero-info-before, home-hero-info, home-hero-info-after, home-hero-actions-before-actions, home-hero-actions-after, home-hero-image.

VPHomeFeatures

Renders the feature cards from the features frontmatter. It has no props.

VPHomeContent

Wraps the markdown content of the home page in a document-styled container:

<VPHomeContent>

## Why another theme

The markdown of the home page goes here.

</VPHomeContent>

The container stretches the team and sponsor sections inside it to the full width of the viewport.

VPHomeSponsors

dataRequiredSponsors[]

The sponsor tiers. Each tier is { tier: string; size?: 'medium' | 'big'; items: Sponsor[] }, and each sponsor is { name: string; img: string; url: string }.

messagestring

The message shown above the sponsors.

actionTextstring
Default'Become a sponsor'

The text of the call-to-action button.

actionLinkstring

The link of the call-to-action button. The button is hidden when it is missing.

<VPHomeSponsors
  message="Thanks to our sponsors!"
  action-text="Become a sponsor"
  action-link="https://github.com/sponsors/vuepress"
  :data="[
    {
      tier: 'Platinum',
      items: [{ name: 'Sponsor', img: '/sponsor.svg', url: 'https://example.com' }],
    },
  ]"
/>

Team Components

A team page is composed of the team components inside the home content. The container is VPHomeContent, which makes the sections stretch to the full width:

<VPHomeContent>

<VPTeamPage>
  <VPTeamPageTitle>
    <template #title>Our Team</template>
    <template #lead>The people who build the project.</template>
  </VPTeamPageTitle>

  <VPTeamPageSection>
    <template #title>Core Team</template>
    <template #lead>The maintainers of the repository.</template>
    <template #members>
      <VPTeamMembers :members="members" />
    </template>
  </VPTeamPageSection>
</VPTeamPage>

</VPHomeContent>

<script setup>
import {
  VPHomeContent,
  VPTeamMembers,
  VPTeamPage,
  VPTeamPageSection,
  VPTeamPageTitle,
} from '@vuepress/theme-default/client'

const members = [
  {
    avatar: 'https://github.com/vuepress.png',
    name: 'VuePress',
    title: 'Maintainer',
    org: 'VuePress',
    orgLink: 'https://vuepress.vuejs.org/',
    desc: 'The team behind the theme.',
    links: [{ icon: 'github', link: 'https://github.com/vuepress' }],
  },
]
</script>

VPTeamPage

The container of the team sections, with a default slot.

VPTeamPageTitle

The title block of the page. It has the title and the lead slots.

VPTeamPageSection

A section of the page. It has the title, the lead and the members slots.

VPTeamMembers

membersRequiredDefaultTheme.TeamMember[]

The members to render. Each member has the fields below.

size'small' | 'medium'
Default'medium'

The size of the cards.

members[*].avatarRequiredstring

The avatar image URL.

members[*].nameRequiredstring

The name of the member.

members[*].titlestring

The title of the member, such as 'Maintainer'.

members[*].orgstring

The organization of the member.

members[*].orgLinkstring

The link of the organization.

members[*].descstring

A short description of the member. HTML is allowed.

members[*].sponsorstring

A link to the sponsor profile of the member. When it is set, the card shows a sponsor link.

members[*].actionTextstring

The text of the sponsor link.

members[*].linksDefaultTheme.SocialLink[]

The social links of the member, each being { icon: string | { svg: string }; link: string; ariaLabel?: string; target?: string }.

VPSponsors

dataRequiredSponsors[] | Sponsor[]

The sponsors. Pass an array of tiers to group them, or a flat array of sponsors for a single group.

tierstring

The title of the group when data is a flat array of sponsors.

size'xmini' | 'mini' | 'small' | 'medium' | 'big'

The size of the logos when data is a flat array of sponsors. A tier may set its own size.

mode'normal' | 'aside'
Default'normal'

The layout of the grid. aside is the compact layout of the document aside.

VPDocAsideSponsors

dataRequiredSponsors[] | Sponsor[]

The sponsors to render, with the same shapes as VPSponsors.

tierstring

The title of the sponsor group.

size'xmini' | 'mini' | 'small'

The size of the logos.

The theme does not mount this component itself. A custom layout fills the aside-ads-after slot of the default layout with it, as shown in Extending.

Generic Components

VPButton

textstring

The text of the button. It is rendered when the default slot is not used.

hrefstring

The link of the button. Without it, the component renders a <button>.

tagstring

The tag to render, a or button.

theme'brand' | 'alt' | 'sponsor'
Default'brand'

The style of the button.

size'medium' | 'big'
Default'medium'

The size of the button.

targetstring

The target attribute of the link.

relstring

The rel attribute of the link.

<VPButton text="Get Started" href="/guide/" />
<VPButton text="GitHub" href="https://github.com/vuepress" theme="alt" />

VPBadge

textstring

The text of the badge. The default slot takes precedence.

type'info' | 'note' | 'tip' | 'important' | 'caution' | 'warning' | 'danger'
Default'tip'

The color of the badge.

A badge <Badge text="New" type="tip" /> in a sentence.

VPImage

imageRequiredDefaultTheme.ThemeableImage

The image. It accepts a URL string, { src, alt? }, or { light, dark, alt? } for a color-mode-aware image.

altstring

The alternative text of the image.

hrefstring

The link target. It is normalized with the base of the site, and an external target opens in a new tab.

tagstring

The tag to render. It defaults to a when href is set, and to span otherwise.

noIconboolean

Whether to hide the external link icon.

externalboolean

Force the link to be treated as external, or as internal when set to false. It is detected from href and target otherwise.

targetstring

The target attribute of the link.

relstring

The rel attribute of the link.

linksRequiredDefaultTheme.SocialLink[]

The social links to render, each being { icon: string | { svg: string }; link: string; ariaLabel?: string; target?: string }.

meboolean
Defaulttrue

Whether the links point to the profiles of the site owner. It is passed to the rel attribute of the links.

VPNavBarSearch

Renders the SearchBox placeholder when a search plugin has registered it, and nothing otherwise. It has no props. The theme renders it in the navbar; a custom layout uses it to keep the search working.

VPThemeIcon

iconRequiredstring

The icon to render. A name from @vuepress/plugin-icon is resolved through the global VPIcon, while a class name starting with vpi- renders the matching theme icon.

VPDocFooterContributors

Renders the contributors line of the document footer from the git data of the page. It has no props, and reads the contributorsText label from the locale config.

MIT Licensed