Components
Built-in and custom components.
These components work in every page without an import, with attributes and slots written as in Markdown.
Built-in Components
Callout
A callout holds a note next to the text. type sets its color and icon:
<Callout type="warn" title="Careful">
This can't be undone.
</Callout>type="info"
type="warn"
type="error"
type="success"
type="idea"
Prop
Type
For markup in the title or the icon, use the title and icon slots instead of the props.
Containers and Alerts
admonitionsPlugin() from vuesho/markdown renders the callouts of VitePress, Fumadocs and GitHub:
import { admonitionsPlugin } from "vuesho/markdown";
createSite(docs.toSource()).plugins(
recommendedPreset(),
admonitionsPlugin(),
);::: warning Watch out
This API is experimental.
:::
::: tip Use `pnpm`
It's faster.
:::
::: details Changelog
The list of changes.
:::The name sets the callout's type, like tip for info and danger for error. ::: details renders as a <details> element, and a name the plugin doesn't know, like ::: code-group, stays as text.
Cards
Cards link to other pages in a grid:
<Cards>
<Card title="Quick Start" href="/">
Create a site from an empty folder.
</Card>
<Card title="Images" href="/markdown/images">
Sizes, placeholders and optimization.
</Card>
</Cards>Prop
Type
Like a callout, a card takes markup in its title and icon slots. Put a blank line between a <template #slot> and the text of the default slot, or the page fails to compile with E-SLOT-PARAGRAPH:
<Card title="Deploying" href="/deploying">
<template #icon>🚀</template>
Put the site online.
</Card>Deploying
Put the site online.
Tabs
Tabs switch between alternatives in prose. items lists the labels, and each <Tab> takes one of them as its value:
<Tabs :items="['Vue', 'React']">
<Tab value="Vue">Write a `.vue` file.</Tab>
<Tab value="React">Write a `.tsx` file.</Tab>
</Tabs>.vue file.Prop
Type
For alternatives in code, code tabs are shorter.
Steps
Steps number a sequence of headings. With stepsPlugin() from vuesho/markdown, a heading that ends with [step] becomes a step. New sites don't include the plugin, so add it first:
import { stepsPlugin } from "vuesho/markdown";
createSite(docs.toSource()).plugins(
recommendedPreset(),
stepsPlugin(),
);#### Install the Package [step]
Run `npm i acme`.
#### Write a Page [step]
Create `content/index.md`.Install the Package
Run npm i acme.
Write a Page
Create content/index.md.
Consecutive [step] headings of the same level form the steps, and a heading of that level or higher without [step] ends them. A step's ID ends with -step, like install-the-package-step. To set the ID yourself, add [#id] after [step].
Without the plugin, write the same steps with <Steps> and <Step>:
<Steps>
<Step>
#### Install the Package
Run `npm i acme`.
</Step>
<Step>
#### Write a Page
Create `content/index.md`.
</Step>
</Steps>Accordions
Accordions collapse content into panels that open on click. With an id, a link like #vue-components opens the panel:
<Accordions>
<Accordion title="Does a site need a server?">
No. A site with only Markdown pages builds to static files.
</Accordion>
<Accordion title="Can a page use Vue components?" id="vue-components">
Yes, any component in `src/components/content/`.
</Accordion>
</Accordions>No. A site with only Markdown pages builds to static files.
Yes, any component in src/components/content/.
Prop
Type
Files
Files draw a tree of folders and files:
<Files>
<Folder name="content" default-open>
<File name="index.md" />
<File name="meta.json" />
</Folder>
<File name="vuesho.config.ts" />
</Files>Prop
Type
With filesPlugin() from vuesho/markdown, a files code block draws the same tree from text, and <auto-files> draws a folder on disk. New sites don't include the plugin, so add it first:
import { filesPlugin } from "vuesho/markdown";
createSite(docs.toSource()).plugins(
recommendedPreset(),
filesPlugin(),
);In a files code block, a name that ends with / is an empty folder:
```files
my-docs
├── content
│ ├── index.md
│ └── guides/
└── vuesho.config.ts
```<auto-files> lists the files in dir that match pattern, and vuesho dev updates the tree when they change:
<auto-files dir="../../src/components" pattern="*.vue" default-open-all />Prop
Type
Type Table
A type table lists an object's fields, like a function's options or a component's props. A row opens to show its full type and description:
<TypeTable
:type="{
dir: {
type: 'string',
description: 'The folder of the collection.',
required: true,
},
depth: {
type: 'number',
description: 'How many levels of folders to list.',
default: '1',
},
}"
/>Prop
Type
For Markdown in a field, use a slot named <field>.<key>:
<TypeTable :type="{ dir: { type: 'string', required: true } }">
<template #dir.description>The folder of the [collection](/markdown/collections).</template>
</TypeTable>To generate type tables from your TypeScript types, see Type Tables.
Image Zoom
An image zoom opens the image at full size on click. Its other attributes, like width and title, go on the <img>:
<ImageZoom src="/screenshots/light.png" alt="The Getting Started page" />
Prop
Type
Lightbox from vuesho/ui/components/image-zoom opens the images inside it in one viewer, where the reader can move between them:
<Lightbox>
<ImageZoom src="/screenshots/light.png" alt="Light mode" title="Light" width="320" />
<ImageZoom src="/screenshots/dark.png" alt="Dark mode" title="Dark" width="320" />
</Lightbox>
<script setup>
import { Lightbox } from "vuesho/ui/components/image-zoom";
</script>

Inline TOC
An inline TOC renders the table of contents inside the page, in a panel that opens on click. Its default slot is the label:
<InlineTOC>On this page</InlineTOC>Custom Components
A .vue file in src/components/content/ is a component that every page can use, by its file name:
<script setup lang="ts">
defineProps<{ text: string }>();
</script>
<template>
<span class="badge">{{ text }}</span>
</template>
<style scoped>
.badge {
padding: 2px 8px;
border-radius: 9999px;
background: var(--color-fd-primary);
color: var(--color-fd-primary-foreground);
font-size: 0.75rem;
}
</style>This feature is <Badge text="new" />.A page loads only the components it uses. Type Checking types each component's props automatically.
A capitalized tag that the folder and the plugins don't provide fails with E-UNKNOWN-COMPONENT. A lowercase tag is an HTML element, except Vue's built-in components, like <component> and <transition>. A collection can have a components folder of its own.
Replacing Elements
A file named after an HTML element, like table.vue, replaces that element in Markdown pages. This component wraps every table in a frame:
<template>
<div class="table-frame">
<table>
<slot />
</table>
</div>
</template>