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.:::::: primaryThis is a tip message.:::::: success SuccessThe operation has completed.:::::: warning WarningPlease confirm the configuration.:::::: danger DangerThis action cannot be undone.:::
Parameters
:::tipis syntax sugar for::: info, and outputsis-default.info,primary,success,warning, anddangermap tois-default,is-primary,is-success,is-warning, andis-danger.- 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="primary" /> <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="primary" size="sm" />
Parameters
text: badge text. If omitted, the content inside the tag is used.theme: defaults todefault, with optional valuesreverse,solid,soft,wash,primary,success,warning,danger,error.size: defaults tomd, with optional valuesm.