Components
vanilla-press builtin components are a set of Markdown container components built on top of vanilla-jui for document layout and interactions.
Components are divided into Container Components and Tag Components:
- Container Components: Syntax starts with
:::, such as::: tabs,::: accordion, etc. - Tag Components: Syntax starts with
<, and with the first letter capitalized, similar toHTMLtags, such as<Badge />, etc.
Container Components
Tabs
JavaScriptconst pages = ['index.md', 'guide/components.md']export function toHtml(file) { return file.replace(/\.md$/, '.html')}
HTML<article class="j-editor is-sm"> <h1>Component Example</h1> <p>Main content uses vanilla-jui content classes.</p></article>
Markdown::: tabs@tab Option AContent A@tab Option BContent B:::
Accordion
docs/en/guide/components.md will be generated to dist/en/guide/components.html, and asset links are resolved automatically.
Code blocks keep language-* classes and render base token styles.
Each page injects its own initDocPage({ components: [...] }) script.
Markdown::: accordion multiple collapsible@item Supports directory-based routing`docs/en/guide/components.md` will be generated to `dist/en/guide/components.html`, and asset links are resolved automatically.@item Supports code highlightingCode blocks keep `language-*` classes and render base token styles.@item Supports page-level component initEach page injects its own `initDocPage({ components: [...] })` script.:::
Parameters
multiple: whether multiple panels can stay expanded at the same time; false when omittedcollapsible: whether all panels can be collapsed; false when omitted
Offcanvas
Offcanvas
In the Offcanvas component, content is wrapped inside a panel container. Click the trigger button to open or close the panel.
Markdown syntax is supported inside the panel content.
JavaScript// javascriptconst pages = ['index.md', 'guide/components.md']export function toHtml(file) { return file.replace(/\.md$/, '.html')}
Markdown::: offcanvas [Open Panel] left### OffcanvasIn the `Offcanvas` component, content is wrapped into a panel. Click the trigger button to open or close it.Markdown syntax is supported inside the panel content.```javascript// javascriptconst pages = ['index.md', 'guide/components.md']export function toHtml(file) { return file.replace(/\.md$/, '.html')}```:::
Parameters
title: button text, written as::: offcanvas [Button Text]; default isOpen Paneldirection: panel direction, written as::: offcanvas [Button Text] direction; supportsleft,right,top, andbottom, withrightas the default
Tip
This is a tip message.
This is a tip message.
The operation has completed.
Please confirm the configuration.
This action cannot be undone.
Markdown::: tipThis is a tip message.:::::: info Custom titleThis is a tip message.:::::: success SuccessThe operation has completed.:::::: warning WarningPlease confirm the configuration.:::::: error ErrorThis action cannot be undone.:::
Parameters
::: tipoutputsj-tipwithout a status class.::: info,::: success,::: warning, and::: erroroutputj-tip is-info,j-tip is-success,j-tip is-warning, andj-tip is-error, respectively.- When no title is provided, Chinese pages show
提示and English pages showTip.
Tree
A component that helps users quickly understand the directory structure of the documentation.
-
my-project/
-
src/
-
components/
-
Header.vue
-
Footer.vue
-
-
App.vue
-
main.js
-
-
public/
-
index.html
-
-
tests/
-
app.test.ts
-
-
package.json
-
README.md
-
Markdown::: treemy-project/├── src/│ ├── components/ [collapsed]│ │ ├── Header.vue│ │ └── Footer.vue│ ├── App.vue│ └── main.js├── public/│ └── index.html├── tests/│ └── app.test.ts├── package.json└── README.md:::
Notes
- File nodes resolve icons by extension and fall back to the
fileicon when no matching icon is registered. - Add
[collapsed]after a folder name to make that folder collapsed by default, for examplecomponents/ [collapsed].
Extend Icons
Add or remove svg icons as needed in src/config/icons.ts.
TypeScriptexport default { 'align-left': '<path d="M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"></path>', 'align-right': '<path d="M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"></path>', copy: '<path d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path>',}
Details
Title
This is a details panel.
Markdown::: details TitleThis is a details panel.:::
Tag Components
Group
The inline container component <Group /> is used to wrap inline HTML or components like Badge.
Markdown<Group gap={8}> <Badge text="apple" /> <Badge text="orange" theme="info" /> <Badge text="banana" theme="warning" /></Group>
Parameters
gap:numberornull. The default value is8, rendered asgap: 8px.
Badge
The badge component <Badge /> can be used directly in headings or body text.
Title new
Inline badges beta can also be inserted in text.
Markdown<Badge text="new" /><Badge text="beta" theme="info" size="sm" />
Parameters
text: badge text. If omitted, the content inside the tag is used.theme: defaults todefault, with optional valuesreverse,solid,soft,wash,info,success,warning,error.size: defaults tomd, with optional valuesm.
Bilibili
The Bilibili component <Bilibili /> embeds a Bilibili video in a document.
Markdown<Bilibili url="https://www.bilibili.com/video/BV1KE411a7EY/" />
Parameters
url: video URL. Required.autoplay: whether to autoplay. Defaults to0, optional value1.ratio: video aspect ratio. Defaults to16 / 9.width: video width. Defaults to100%.t: playback start time. Defaults to0, in seconds.muted: whether to mute the video. Defaults to0, optional value1.p: part index. Defaults to1.danmaku: whether to show danmaku comments. Defaults to0, optional value1.no-related/norelated: whether to hide related videos. Defaults to0, optional value1.height: video height. Defaults to null, so no height is set.
Youtube
The Youtube component <Youtube /> embeds a Youtube video in a document.
Markdown<Youtube url="https://www.youtube.com/watch?v=0Puv0Pss33M" />
Parameters
url: video URL or video ID. Required. Supportsyoutube.com/watch?v=,youtu.be,youtube.com/embed,youtube.com/shorts, andyoutube.com/live.autoplay: whether to autoplay. Defaults to0, optional value1.controls: whether to show player controls. Defaults to1, optional value0.ratio: video aspect ratio. Defaults to16 / 9.width: video width. Defaults to100%.start/t: playback start time. Defaults to0, in seconds.end: playback end time. Defaults to0, in seconds.muted: whether to mute the video. Defaults to0, optional value1.loop: whether to loop playback. Defaults to0, optional value1.no-related/norelated: whether to limit related video recommendations. Defaults to0, optional value1.height: video height. Defaults to null, so no height is set.