vitepress-plugin-sandpack
use sandpack-vue3 in vitepress as directive.
194,903
57
| Install | |
|---|---|
npm install vitepress-plugin-sandpack |
|
| Latest Version: | 1.1.4 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jan 30, 2024 |
| Links: | GitHub · npm |
Maintainer: wc57242263

install
This is plugin for vitepress that give you the power of editable sandboxes that run in the browser.
Language support: angular | react | react-ts | vanilla | vanilla-ts | vue | vue3 | vue3-ts | svelte | solid | test-ts.
-
install package
cd project-folder npm i vitepress-plugin-sandpack -DTIPS: for
pnpmyou need:
pnpm add markdown-it-container -D -
edit theme config, register global component
docs/.vitepress/theme/index.tsimport DefaultTheme from 'vitepress/theme'; +import { Sandbox } from 'vitepress-plugin-sandpack'; +import 'vitepress-plugin-sandpack/dist/style.css'; export default { ...DefaultTheme, enhanceApp(ctx) { DefaultTheme.enhanceApp(ctx); + ctx.app.component('Sandbox', Sandbox); }, } -
edit config
docs/.vitepress/config.tsimport { defineConfig } from 'vitepress'; import container from 'markdown-it-container'; import { renderSandbox } from 'vitepress-plugin-sandpack'; // rule of 'html tag name' to 'component name' // 'sanbox' -> 'Sandbox' // 'my-sandbox' -> MySandbox // 'sandbox-react-demo' -> SandboxReactDemo export default defineConfig({ // ... markdown: { config(md) { md // the second parameter is html tag name .use(container, 'sandbox', { render (tokens, idx) { return renderSandbox(tokens, idx, 'sandbox'); }, }); }, }, // ... })
document
how to use
-
code in markdown file

-
preview in browser
light mode

dark mode

use file snippets
Sponsor
Special Sponsor
Related Packages
@red-asuka/vitepress-plugin-tabs
VitePress plugin - markdown custom container to display content in tabs
49,189
10
vp-dynamic-nav
VitePress plugin that fetches and renders the navbar dynamically from a remote J...
4,229
vitepress-plugin-component
VitePress plugin that renders Vue components with tabs showing preview and sourc...
1,132
2
Version History
| Version | Released | License |
|---|---|---|
| 1.1.4 | MIT | |
| 1.1.3 | MIT | |
| 1.1.2 | MIT | |
| 1.1.1 | MIT | |
| 1.1.0 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.3.2 | MIT | |
| 0.3.1 | MIT | |
| 0.3.0 | MIT | |
| 0.2.3 | MIT | |
| 0.2.2 | MIT | |
| 0.2.1 | MIT | |
| 0.2.0 | MIT | |
| 0.1.2 | MIT | |
| 0.1.1 | MIT | |
| 0.1.0 | MIT |
Pre-releases (4)
| Version | Released | License |
|---|---|---|
| 0.1.0-beta.3 | MIT | |
| 0.1.0-beta.2 | MIT | |
| 0.1.0-beta.1 | MIT | |
| 0.1.0-beta.0 | MIT |