1. Project Overview & Quickstart (slidevjs/slidev)
File: README.md
Features
- ๐ Markdown-based - focus on content and use your favorite editor
- ๐งโ๐ป Developer Friendly - built-in code highlighting, live coding, etc.
- ๐จ Themable - theme can be shared and used with npm packages
- ๐ Stylish - on-demand utilities via UnoCSS.
- ๐คน Interactive - embedding Vue components seamlessly
- ๐ Presenter Mode - use another window, or even your phone to control your slides
- ๐จ Drawing - draw and annotate on your slides
- ๐งฎ LaTeX - built-in LaTeX math equations support
- ๐ฐ Diagrams - creates diagrams using textual descriptions with Mermaid
- ๐ Icons - access to icons from any icon set directly
- ๐ป Editor - integrated editor, or the VSCode extension
- ๐ฅ Recording - built-in recording and camera view
- ๐ค Portable - export into PDF, PNGs, or PPTX
- โก๏ธ Fast - instant reloading powered by Vite
- ๐ Hackable - using Vite plugins, Vue components, or any npm packages
Getting Started
Try it Online โก๏ธ
Init Project Locally
Install Node.js >= 20.12.0 and run the following command:
npm init slidevDocumentation:
English | ไธญๆๆๆกฃ | Franรงais | Espaรฑol | ะ ัััะบะธะน | Portuguรชs-BR
Discord: chat.sli.dev
For a full example, you can check the demo folder, which is also the source file for my previous talk.
Tech Stack
- Vite - An extremely fast frontend tooling
- Vue 3 powered Markdown - Focus on the content while having the power of HTML and Vue components whenever needed
- UnoCSS - On-demand utility-first CSS engine, style your slides at ease
- Shiki, Monaco Editor - First-class code snippets support with live coding capability
- RecordRTC - Built-in recording and camera view
- VueUse family -
@vueuse/core,@vueuse/motion, etc. - Iconify - Icon sets collection.
- Drauu - Drawing and annotations support
- KaTeX - LaTeX math rendering.
- Mermaid - Textual Diagrams.
Sponsors
This project is made possible by all the sponsors supporting my work:
License
MIT License ยฉ 2021 Anthony Fu
File: demo/starter/README.md
See ../../packages/create-app/template/README.md
File: demo/README.md
The best way of understanding Slidev is to try it, with the following command:
npm init slidevLearn more: https://sli.dev
File: docs/builtin/cli.md
Slidev CLI
@slidev/cli exposes a binary called slidev that you can use to develop, build, and export your slides.
Prerequisites
To use the CLI, you can either install @slidev/cli globally or install it locally in your Node.js project. If you created your project with npm init slidev, the CLI is already installed locally.
::: warning
Usually npx slidev is not supported because the package name is actually @slidev/cli.
:::
The CLI options of the commands obey the following conventions:
the value of the option can be passed after a space or a
=character:Example:
slidev --port 8080is equivalent toslidev --port=8080truecan be omitted for boolean options:Example:
slidev --openis equivalent toslidev --open true
::: info
If you use npm, please don't forget to add -- before the options to pass them to Slidev:
npm run slidev -- --remote --port 8080 --open:::
`slidev [entry]` {#dev}
Start a local server for Slidev.
[entry](string, default:slides.md): path to the markdown file containing your slides.
Options:
--port,-p(number, default:3030): port number.--base(string, default:/): base URL (see https://vitejs.dev/config/shared-options.html#base).--open,-o(boolean, default:false): open in the browser.--remote [password](string): listen to the public host and enable remote control, if a value is passed then the presenter mode is private and only accessible by passing the given password in the URL querypasswordparameter.--bind(string, default:0.0.0.0): specify which IP addresses the server should listen on in the remote mode.--log('error', 'warn', 'info', 'silent', default:'warn'): Log level.--force,-f(boolean, default:false): force the optimizer to ignore the cache and re-bundle.--theme,-t(string): override theme.
`slidev build [entry]` {#build}
Build a hostable SPA. See
[entry](string, default:slides.md): path to the slides markdown file.
Options:
--out,-o(string, default:dist): output directory--base(string, default:/): base URL (see https://vitejs.dev/config/shared-options.html#base)--download(boolean, default:false): allow the download of the slides as a PDF inside the SPA--theme,-t(string): override theme--without-notes(boolean, default:false): exclude speaker notes from the SPA
`slidev export [...entry]` {#export}
Export slides to PDF (or other format). See
[entry](string, default:slides.md): path to the slides markdown entry.
Options:
--output(string, default: useexportFilename(see https://sli.dev/custom/#frontmatter-configures) or use[entry]-export): path to the output.--format('pdf', 'png', 'pptx', 'md', default:'pdf'): output format.--timeout(number, default:30000): timeout for rendering the print page (see https://playwright.dev/docs/api/class-page#page-goto).--range(string): page ranges to export (example:'1,4-5,6').--dark(boolean, default:false): export as dark theme.--with-clicks,-c(boolean, default:false): export pages for every click animation (see https://sli.dev/guide/animations.html#click-animation).--theme,-t(string): override theme.--omit-background(boolean, default:false): remove the default browser background
`slidev format [entry]` {#format}
Format the markdown file. Note that this won't format the content of the slides, only the organization of the markdown file.
[entry](string, default:slides.md): path to the slides markdown entry.
`slidev mcp [entry]` {#mcp}
Start an MCP (Model Context Protocol) server over stdio for AI agents to inspect and edit the slides. See
[entry](string, default:slides.md): path to the slides markdown entry.
`slidev theme [subcommand]` {#theme}
Theme-related operations.
Subcommands:
eject [entry]: Eject the current theme into the local file system. See. [entry](string, default:slides.md): path to the slides markdown entry.- Options:
--dir(string, default:theme): the output dir.--theme,-t(string): override theme.
File: docs/builtin/components.md
Components
This page lists all the built-in components provided by Slidev. These components can be directly used in your slides.
Note that
`Arrow`
Draw an arrow.
Usage
<Arrow x1="10" y1="20" x2="100" y2="200" />Or:
<Arrow v-bind="{ x1:10, y1:10, x2:200, y2:200 }" />Props:
x1(string | number, required): start point x positiony1(string | number, required): start point y positionx2(string | number, required): end point x positiony2(string | number, required): end point y positionwidth(string | number, default:2): line widthcolor(string, default:'currentColor'): line colortwo-way(boolean, default:false): draw a two-way arrow
`VDragArrow`
An Arrow component that can be dragged.
Usage
Props not related to position are the same as the Arrow component.
`AutoFitText`
Box inside which the font size will automatically adapt to fit the content, powered by fitty. Similar to PowerPoint or Keynote TextBox.
Usage
<AutoFitText :max="200" :min="100" modelValue="Some text"/>Props:
max(number, default100): Maximum font size in pixelsmin(number, default30): Minimum font size in pixelsmodelValue(string, default''): Text content (alternatively, use the default slot)multiLine(boolean, defaulttrue): Allow the text to wrap when the minimum font size is reached
`LightOrDark`
Use it to display one thing or another depending on the active light or dark theme.
Usage
Use it with the two named Slots #dark and #light:
<LightOrDark>
<template #dark>Dark mode is on</template>
<template #light>Light mode is on</template>
</LightOrDark>Provided props on LightOrDark component will be available using scoped slot props:
<LightOrDark width="100" alt="some image">
<template #dark="props">
</template>
<template #light="props">
</template>
</LightOrDark>You can provide markdown in the slots, but you will need to surround the content with blank lines:
<LightOrDark>
<template #dark>
</template>
<template #light>
</template>
</LightOrDark>`Link`
Insert a link you can use to navigate to a given slide.
Usage
<Link to="42">Go to slide 42</Link>
<Link to="42" title="Go to slide 42"/>
<Link to="solutions" title="Go to solutions"/>Props:
to(string | number): The path of the slide to navigate to (slides path starts from1)title(string): The title to display
One can use a string as to, provided the corresponding route exists, e.g.
---
routeAlias: solutions
---
# Now some solutions!`PoweredBySlidev`
Renders "Powered by Slidev" with a link to the Slidev website.
`RenderWhen`
Render slots depend on whether the context matches (for example whether we are in presenter view).
Usage
<RenderWhen context="presenter">This will only be rendered in presenter view.</RenderWhen>Context type: 'main' | 'visible' | 'print' | 'slide' | 'overview' | 'presenter' | 'previewNext'
Props:
context(Context | Context[]): a context or array of contexts you want to check for'main': Render in slides and presenter view (equivalent to ['slide', 'presenter']),'visible': Render the content if it is visible'print': Render in print mode'slide': Render in slides'overview': Render in overview'presenter': Render in presenter view'previewNext': Render in presenter's next slide view
Slots:
#default: Rendered when the context matches#fallback: Rendered when the context does not match
`SlideCurrentNo`
Current slide number.
Usage
<SlideCurrentNo />`SlidesTotal`
Total number of slides.
Usage
<SlidesTotal />`TitleRenderer`
Insert the main title from a slide parsed as HTML.
Titles and title levels get automatically retrieved from the first title element of each slide.
You can override this automatic behavior for a slide by using the front matter syntax:
---
title: Amazing slide title
level: 2
---Usage
The <TitleRenderer> component is a virtual component you can import with:
import TitleRenderer from '#slidev/title-renderer'Then you can use it with:
<TitleRenderer no="42" />Props:
no(string | number): The number of the slide to display the title from (slides starts from1)
`Toc`
Insert a Table Of Content.
If you want a slide to not appear in the <Toc> component, you can use the hideInToc option in the frontmatter of the slide:
---
hideInToc: true
---Titles are displayed using the <Titles> component
Usage
<Toc />Props:
columns(string | number, default:1): The number of columns of the displaylistClass(string | string[], default:''): Classes to apply to the table of contents listmaxDepth(string | number, default:Infinity): The maximum depth level of title to displayminDepth(string | number, default:1): The minimum depth level of title to displaymode('all' | 'onlyCurrentTree'| 'onlySiblings', default:'all'):'all': Display all items'onlyCurrentTree': Display only items that are in current tree (active item, parents and children of active item)'onlySiblings': Display only items that are in current tree and their direct siblings
`Transform`
Apply scaling or transforming to elements.
Usage
<YourElements />Props:
scale(number | string, default1): transform scale valueorigin(string, default'top left'): transform origin value
`Tweet`
Embed a tweet.
Usage
<Tweet id="20" />Props:
id(number | string, required): id of the tweetscale(number | string, default1): transform scale valueconversation(string, default'none'): tweet embed parametercards('hidden' | 'visible', default'visible'): tweet embed parameter
`BlueSky`
Embed a Bluesky post.
Usage
Props:
uri(string, required): AT-URI of the Bluesky post, or ahttps://bsky.app/profile/.../post/...URLscale(number | string, default1): transform scale value
`VAfter`, `VClick` and `VClicks`
`VSwitch`
Switch between multiple slots based on clicks.
- If the
unmountprop is set totrue, the previous slot will be unmounted when switching to the next slot. Default isfalse. - Use the
tagandchildTagprops to change the default tag of the component and its children. Default isdiv. - Use the
transitionprop to change the transition effect. Default isfalse(disabled).
`VDrag`
`SlidevVideo`
Embed a video.
Usage
<SlidevVideo v-click autoplay controls>
Your browser does not support videos. You may download it
[here](/myMovie.mp4).
</SlidevVideo>Check HTML video element's doc to see what can be included in this component's slot.
Props:
controls(boolean, default:false): show the video controlsautoplay(boolean | 'once', default:false):trueor'once': start the video only once and does not restart it once ended or pausedfalse: never automatically start the video (rely oncontrolsinstead)
autoreset('slide' | 'click', default:undefined):'slide': go back to the start of the video when going back to the slide'click': go back to the start of the video when going back to the component's click turn
poster(string | undefined, default:undefined):- The source of the image to print when the video is not playing.
printPoster(string | undefined, default:undefined):- The override for
posterwhen printing.
- The override for
timestamp(string | number, default:0):- The starting time of the video in seconds.
printTimestamp(string | number | 'last' | undefined, default:undefined):- The override for
timestampwhen printing.
- The override for
::: warning
When exporting, the video may fail to load because Chromium does not support some video formats. In this case, you can specify the executable path of the browser. See Chromium executable path for more information.
:::
`Youtube`
Embed a YouTube video.
Usage
<Youtube id="luoMHjh-XcQ" />Props:
id(string, required): id of the YouTube videowidth(number): width of the videoheight(number): height of the video
You can also make the video start at a specific time if you add ?start=1234 to the id value (where 1234 is seconds),
File: docs/builtin/layouts.md
Layouts
This page lists all the built-in layouts provided by Slidev. These layouts can be used via the layout option in the frontmatters of your slides.
Note that
`center`
Displays the content in the middle of the screen.
`cover`
Used to display the cover page for the presentation, may contain the presentation title, contextualization, etc.
`default`
The most basic layout, to display any kind of content.
`end`
The final page for the presentation.
`fact`
To show some fact or data with a lot of prominence on the screen.
`full`
Use all the space of the screen to display the content.
`image-left`
Shows an image on the left side of the screen, the content will be placed on the right side.
Usage
---
layout: image-left
# the image source
image: /path/to/the/image
# a custom class name to the content
class: my-cool-content-on-the-right
---`image-right`
Shows an image on the right side of the screen, the content will be placed on the left side.
Usage
---
layout: image-right
# the image source
image: /path/to/the/image
# a custom class name to the content
class: my-cool-content-on-the-left
---`image`
Shows an image as the main content of the page.
Usage
---
layout: image
# the image source
image: /path/to/the/image
---You can change the default background size (cover) by adding the backgroundSize attribute:
---
layout: image
image: /path/to/the/image
backgroundSize: contain
------
layout: image-left
image: /path/to/the/image
backgroundSize: 20em 70%
---`iframe-left`
Shows a web page on the left side of the screen, the content will be placed on the right side.
Usage
---
layout: iframe-left
# the web page source
url: https://github.com/slidevjs/slidev
# a custom class name to the content
class: my-cool-content-on-the-right
---`iframe-right`
Shows a web page on the right side of the screen, the content will be placed on the left side.
Usage
---
layout: iframe-right
# the web page source
url: https://github.com/slidevjs/slidev
# a custom class name to the content
class: my-cool-content-on-the-left
---`iframe`
Shows a web page as the main content of the page.
Usage
---
layout: iframe
# the web page source
url: https://github.com/slidevjs/slidev
---`intro`
To introduce the presentation, usually with the presentation title, a short description, the author, etc.
`none`
A layout without any existing styling.
`quote`
To display a quotation with prominence.
`section`
Used to mark the beginning of a new presentation section.
`statement`
Make an affirmation/statement as the main page content.
`two-cols`
Separates the page content in two columns.
Usage
---
layout: two-cols
---
# Left
This shows on the left
::right::
# Right
This shows on the right`two-cols-header`
Separates the upper and lower lines of the page content, and the second line separates the left and right columns.
Usage
---
layout: two-cols-header
---
This spans both
::left::
# Left
This shows on the left
::right::
# Right
This shows on the right
<style>
.two-cols-header {
column-gap: 20px; /* Adjust the gap size as needed */
}
</style>File: docs/custom/config-code-runners.md
Configure Code Runners
Define code runners for custom languages in your Monaco Editor.
By default, JavaScript, TypeScript runners are supported built-in. They run in the browser without a sandbox environment. If you want more advanced integrations, you can provide your own code runner that sends the code to a remote server, runs in a Web Worker, or anything, up to you.
Create ./setup/code-runners.ts with the following content:
/* eslint-disable import/first */
declare const executePythonCodeRemotely: (code: string) => Promise<string>
declare const sanitizeHtml: (html: string) => string
// ---cut---
import { defineCodeRunnersSetup } from '@slidev/types'
export default defineCodeRunnersSetup(() => {
return {
async python(code, ctx) {
// Somehow execute the code and return the result
const result = await executePythonCodeRemotely(code)
return {
text: result
}
},
html(code, ctx) {
return {
html: sanitizeHtml(code)
}
},
// or other languages, key is the language id
}
})Runner Context
The second argument ctx is the runner context, which contains the following properties:
import type { CodeRunnerOutputs } from '@slidev/types'
import type { CodeToHastOptions } from 'shiki'
// ---cut---
export interface CodeRunnerContext {
/**
* Options passed to runner via the `runnerOptions` prop.
*/
options: Record<string, unknown>
/**
* Highlight code with shiki.
*/
highlight: (code: string, lang: string, options?: Partial<CodeToHastOptions>) => string
/**
* Use (other) code runner to run code.
*/
run: (code: string, lang: string) => Promise<CodeRunnerOutputs>
}Runner Output
The runner can either return a text or HTML output, or an element to be mounted. Refer to https://github.com/slidevjs/slidev/blob/main/packages/types/src/code-runner.ts for more details.
Additional Runner Dependencies
By default, Slidev will scan the Markdown source and automatically import the necessary dependencies for the code runners. If you want to manually import dependencies, you can use the monacoRunAdditionalDeps option in the headmatter:
monacoRunAdditionalDeps:
- ./path/to/dependency
- lodash-es::: tip
The paths are resolved relative to the snippets directory. And the names of the deps should be exactly the same as the imported ones in the code.
:::
File: docs/custom/config-context-menu.md
Configure Context Menu
Customize the context menu items in Slidev.
Create ./setup/context-menu.ts with the following content:
// ---cut---
import { useNav } from '@slidev/client'
import { defineContextMenuSetup } from '@slidev/types'
import { computed } from 'vue'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import Icon3DCursor from '~icons/carbon/3d-cursor'
export default defineContextMenuSetup((items) => {
const { isPresenter } = useNav()
return computed(() => [
...items.value,
{
small: false,
icon: Icon3DCursor, // if `small` is `true`, only the icon is shown
label: 'Custom Menu Item', // or a Vue component
action() {
alert('Custom Menu Item Clicked!')
},
disabled: isPresenter.value,
},
])
})This will append a new menu item to the context menu.
To disable context menu globally, set contextMenu to false in the frontmatter. contextMenu can also be set to dev or build to only enable the context menu in development or build mode.
File: docs/custom/config-fonts.md
Configure Fonts
While you can use HTML and CSS to customize the fonts and style for your slides as you want, Slidev also provides a convenient way to use them effortlessly.
In your frontmatter, configure as the following:
---
fonts:
# basically the text
sans: Robot
# use with `font-serif` css class from UnoCSS
serif: Robot Slab
# for code blocks, inline code, etc.
mono: Fira Code
---And that's all.
Fonts will be imported automatically from a provider via CDN, by default it is Google Fonts. That means you can use any fonts available on Google Fonts directly.
Local Fonts
By default, Slidev assumes all the fonts specified via fonts configurations come from Google Fonts. If you want to use local fonts, specify the fonts.local to opt-out the auto-importing.
---
fonts:
# like font-family in css, you can use `,` to separate multiple fonts for fallback
sans: 'Helvetica Neue,Robot'
# mark 'Helvetica Neue' as local font
local: Helvetica Neue
---Weights & Italic
By default, Slidev imports three weights 200,400,600 for each font. You can configure them by:
---
fonts:
sans: Robot
# default
weights: '200,400,600'
# import italic fonts, default `false`
italic: false
---This configuration applies to all web fonts. For more fine-grained controls of each font's weights, you will need to manually import them with HTML and CSS.
Fallback Fonts
For most of the scenarios, you only need to specify the "special font" and Slidev will append the fallback fonts for you, for example:
---
fonts:
sans: Robot
serif: Robot Slab
mono: Fira Code
---will result in
.font-sans {
font-family: "Robot",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
}
.font-serif {
font-family: "Robot Slab",ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;
}
.font-mono {
font-family: "Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
}If you want to disable the fallback fonts, configure as the following:
---
fonts:
mono: 'Fira Code, monospace'
fallbacks: false
---Providers
- Options:
google|coollabs|none - Default:
google
Currently, only Google Fonts and coolLabs supported, we are planning to add more providers in the future. Specify to none will disable the auto-importing feature entirely and treat all the fonts locally.
---
fonts:
provider: none
---File: docs/custom/config-highlighter.md
Configure Highlighter
Slidev uses Shiki as the code highlighter. It's a TextMate Grammar powered syntax highlighter as accurate as VS Code. It generates colored tokens so no additinal CSS is required. Shiki also comes with a bunch of built-in themes. In Slidev, we also provided the TwoSlash support.
Configure Shiki
Create ./setup/shiki.ts file with the following content:
import { defineShikiSetup } from '@slidev/types'
export default defineShikiSetup(() => {
return {
themes: {
dark: 'min-dark',
light: 'min-light',
},
transformers: [
// ...
],
}
})If you want to add custom theme or language (TextMate grammar/themes in JSON), you can import them in the setup file:
import { defineShikiSetup } from '@slidev/types'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import customLanguage from './customLanguage.tmLanguage.json'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import customTheme from './customTheme.tmTheme.json'
export default defineShikiSetup(() => {
return {
themes: {
dark: customTheme,
light: 'min-light',
},
langs: [
'js',
'typescript',
'cpp',
customLanguage,
// ...
],
transformers: [
// ...
],
}
})Check Built-in languages and Built-in themes, and refer to Shiki's docs for more details.
:::info
For now, Shiki Magic Move does not support transformers.
:::
Configure Prism
:::warning
Prism support has been removed since v0.50. Please use Shiki instead.
:::
2. Official Technical Reference & Guides (slidevjs/docs)
File: README.md
[sli.dev](https://sli.dev)
[!IMPORTANT]
This repository is a mirror of thedocs/directory in slidevjs/slidev. Mainly for other translations repositories to sync.โผ๏ธ Please DO NOT submit pull requests here โผ๏ธ. Instead, send them to the main repository, and they will be synced here automatically.
Mirrored documentation site for Slidev
Translations
| Repo | Site | Maintainers | |
|---|---|---|---|
| English | docs | sli.dev | @antfu |
| ็ฎไฝไธญๆ | docs-cn | cn.sli.dev | @QC-L @Ivocin |
| Franรงais | docs-fr | fr.sli.dev | @ArthurDanjou |
| Espaรฑol | docs-es | es.sli.dev | @owlnai |
| ะ ัััะบะธะน | docs-ru | ru.sli.dev | @xesjkeee |
| Viแปt Nam | docs-vn | vn.sli.dev | @bongudth |
| Deutsch | docs-de | de.sli.dev | @fabiankachlock |
| Portuguรชs (BR) | docs-br | br.sli.dev | @luisfelipesdn12 |
| ฮฮปฮปฮทฮฝฮนฮบฮฌ | docs-el | el.sli.dev | @GeopJr |
| ๆฅๆฌ่ช | docs-ja | ja.sli.dev | @IkumaTadokoro |
Start Server Locally
npm i pnpm
pnpm i
pnpm run devAnd then visit http://localhost:3000
Or install the Vite extension for VS Code to edit side-by-side.
Help on Translating
See TRANSLATIONS.md
File: docs/custom/config-context-menu.md
Configure Context Menu
Customize the context menu items in Slidev.
Create ./setup/context-menu.ts with the following content:
import { defineContextMenuSetup } from '@slidev/types'
import { computed } from 'vue'
import Icon3DCursor from '~icons/carbon/3d-cursor'
export default defineContextMenuSetup((items) => {
const { isPresenter } = useNav()
return computed(() => [
...items.value,
{
small: false,
icon: Icon3DCursor, // Used as `title` if `small` is `true`
label: 'Custom Menu Item', // or a Vue component
action() {
alert('Custom Menu Item Clicked!')
},
disabled: isPresenter.value,
},
])
})This will append a new menu item to the context menu.
To disable context menu globally, set contextMenu to false in the frontmatter. contextMenu can also be set to dev or build to only enable the context menu in development or build mode.
File: docs/custom/config-routes.md
Configure Routes
Add your pages to the Slidev app.
Usage
Create ./setup/routes.ts with the following content:
import { defineRoutesSetup } from '@slidev/types'
export default defineRoutesSetup((routes) => {
return [
...routes,
{
path: '/my-page',
component: () => import('../pages/my-page.vue'),
},
]
})Learn more about routes in the Vue Router documentation.
File: docs/guide/draggable.md
Draggable Elements
Draggable elements give you the ability to move, resize and rotate elements by dragging them with the mouse. This is useful for creating floating elements in your slides.
Directive Usage
Data from the frontmatter
---
dragPos:
square: Left,Top,Width,Height,Rotate
---Data from the directive value
::: warning
Slidev use regex to update the position value in the slide content. If you meet problems, please use the frontmatter to define the values instead.
:::
Component Usage
Data from the frontmatter
---
dragPos:
foo: Left,Top,Width,Height,Rotate
---
<v-drag pos="foo" text-3xl>
<carbon:arrow-up />
Use the `v-drag` component to have a draggable container!
</v-drag>Data from props
<v-drag pos="Left,Top,Width,Height,Rotate" text-3xl>
<carbon:arrow-up />
Use the `v-drag` component to have a draggable container!
</v-drag>Automatic Height
You can set Height to NaN (if you use the directive) or _ (if you use the component) to make the height of the draggable element automatically adjust to its content.
Create a Draggable Element
When you first create a draggable element, you don't need to specify the position value (but you need to specify the position name if you want to use the frontmatter). Slidev will automatically generate the initial position value for you.
Controls
- Double click the draggable element to start dragging it.
- You can also use the arrow keys to move the element.
- Hold
Shiftwhile dragging to preserve its aspect ratio. - Click outside the draggable element to stop dragging it.
Draggable Arrow
The <v-drag-arrow> component creates a draggable arrow element. Simply use it like this:
<v-drag-arrow />And you will get a draggable arrow element. Other props are the same as the Arrow component.
File: docs/guide/overview.md
Slide Overview
Available since v0.48.0
You can visit an overview of all of your slides by clicking the http://localhost:3030/overview directly.
The overview page gives you a linear list of all your slides, with all of your notes on the side. You can double click on the notes to edit the notes directly, or drag the clicks sliders to preview the steps in your slides.
File: guide/animations.md
outline: deep
Animations
Click Animations
[!NOTE]
Since v0.48.0, we are rewritten the click animations system with much more consistent behaviors. It might change the behaviors of your existing slides in edge cases. While this page is showing the new click system, you can find more details about the refactor in #1279.
`v-click`
To apply "click animations" for elements, you can use the v-click directive or <v-click> components
<v-click> Hello **World** </v-click>
Hey!`v-after`
v-after is only provided as a directive. It will turn the element visible when the previous v-click is triggered.
Hello
WorldWhen you press "next", both Hello and World will show up together.
Hide after clicking
Add a .hide modifier to v-click or v-after to make the element invisible after clicking, instead of showing up.
Visible after 1 click
Hidden after 2 click
Hidden after 2 clickFor v-click component, you can use the hide prop to achieve the same effect:
<v-click> Visible after 1 click </v-click>
<v-click hide> Hidden after 2 click </v-click>`v-clicks`
v-clicks is only provided as a component. It's a shorthand to apply the v-click directive to all its child elements. It is especially useful when working with lists and tables.
<v-clicks>
- Item 1
- Item 2
- Item 3
</v-clicks>An item will become visible each time you click "next".
It accepts a depth prop for nested list:
<v-clicks depth="2">
- Item 1
- Item 1.1
- Item 1.2
- Item 2
- Item 2.1
- Item 2.2
</v-clicks>Also, you can use the every prop to specify the number of items to show after each click:
<v-clicks every="2">
- Item 1 (part 1)
- Item 1 (part 2)
- Item 2 (part 1)
- Item 2 (part 2)
</v-clicks>Positioning
By default, the clicking animations take place one by one. You can customize the animation position of elements by using the at prop or the v-click directive with value.
Like the CSS layout system, click-animated elements can be "relative" or "absolute":
Relative Position
This actual position of relative elements are calculated based on the previous relative elements:
visible after 1 click
<v-click at="+2"> visible after 3 clicks </v-click>
hidden after 2 clicks
```js {none|1|2}{at:'+5'}
1 // highlighted after 7 clicks
2 // highlighted after 8 clicks
```[!NOTE]
The default value ofv-clickis'+1'when you don't specify it.
In fact, v-after are just shortcuts for v-click with at prop:
<v-click-gap size="1" />:::info
Only string values start with '+' or '-' like '+1' are treated as relative positions:
| Value | Kind |
|---|---|
'-1', '+1' |
Relative |
+1 === 1 |
Absolute |
'1' |
Absolute |
So don't forget the single quotes for the relative values.
:::
Absolute Position
The given value is the exact click count to show the element:
visible after 3 clicks
<v-click at="2"> visible after 2 clicks </v-click>
hidden after 1 click
```js {none|1|2}{at:3}
1 // highlighted after 3 clicks
2 // highlighted after 4 clicks
```Mixed Case
You can mix the absolute and relative positions:
visible after 1 click
visible after 3 clicks
visible after 2 click
visible after 1 click
visible after 4 clicksThe following example synchronizes the highlighting of the two code blocks:
```js {1|2}{at:1}
1 + 1
'a' + 'b'
```
```js {1|2}{at:1}
2
'ab'
```Enter & Leave
You can also specify the enter and leave index for the v-click directive by passing an array. The end index is exclusive.
This will be hidden at click 2 and 3.
This will be shown at click 3, and hidden since click 4.You can also use v-switch to achieve the same effect:
<v-switch>
<template #1> show at click 1, hide at click 2. </template>
<template #2> show at click 2, hide at click 5. </template>
<template #5-7> show at click 5, hide at click 7. </template>
</v-switch>See VSwitch Component for more details.
Custom Total Clicks Count
By default, Slidev counts how many steps are needed before going to the next slide. You can override this setting by passing the clicks frontmatter option:
---
# 10 clicks in this slide, before going to the next
clicks: 10
---Element Transitions
When you apply the v-click directive to your elements, it will attach the class name slidev-vclick-target to it. When the elements are hidden, the class name slidev-vclick-hidden will also be attached. For example:
TextAfter a click, it will become
TextBy default, a subtle opacity transition is applied to those classes:
// the default
.slidev-vclick-target {
transition: opacity 100ms ease;
}
.slidev-vclick-hidden {
opacity: 0;
pointer-events: none;
}You can override them to customize the transition effects in your custom stylesheets.
For example, you can achieve the scaling up transitions by:
/* styles.css */
.slidev-vclick-target {
transition: all 500ms ease;
}
.slidev-vclick-hidden {
transform: scale(0);
}To specify animations for only certain slide or layout
.slidev-page-7,
.slidev-layout.my-custom-layout {
.slidev-vclick-target {
transition: all 500ms ease;
}
.slidev-vclick-hidden {
transform: scale(0);
}
}Learn more about customizing styles.
Rough Markers
Available since v0.48.0
Slidev integrates Rough Notation to allow marking or highlighting elements in your slides.
`v-mark`
Rough Notation integrates comes with the v-mark directive.
Type
v-mark.underline for Underline mark, v-mark.circle for Circle mark, etc. Default to underline
Color
v-mark.red make the notation red. Supported builtin color themes from UnoCSS. For custom colors, use object syntax v-mark="{ color: '#234' }"
Clicks
v-mark works like v-click and will trigger after a click. Same as v-click, it allows you to pass a custom click value, like v-mark="5" or v-mark="'+1'".
Options
Optionally you can pass an object to v-mark to specify the options, for example:
Important textPreview
Motion
Slidev has @vueuse/motion built-in. You can use the v-motion directive to any elements to make apply motion on them. For example
SlidevThe text Slidev will move from -80px to its original position on initialization.
Note: Slidev preloads the next slide for performance, which means the animations might start before you navigate to the page. To get it works properly, you can disable the preloading for the particular slide
md--- preload: false ---Or control the element life-cycle with
v-ifto have fine-grained controlshtmlv-if="$slidev.nav.currentPage === 7" v-motion :initial="{ x: -80 }" :enter="{ x: 0 }"> Slidev
Learn mode: Demo | @vueuse/motion | v-motion | Presets
Slide Transitions
Available since v0.39.0
Slidev supports slide transitions out of the box. You can enable it by setting the transition frontmatter option:
---
transition: slide-left
---This will give you a nice sliding effects on slide switching. Setting it in the frontmatter will apply to all slides. You can also set different transition per slide.
Builtin Transitions
fade- Crossfade in/outfade-out- Fade out and then fade inslide-left- Slides to the left (slide to right when going backward)slide-right- Slides to the right (slide to left when going backward)slide-up- Slides to the top (slide to bottom when going backward)slide-down- Slides to the bottom (slide to top when going backward)view-transition- Slides with the view transitions API
View Transitions
Available since v0.43.0
The View Transitions API provides a mechanism for easily creating animated transitions between different DOM states. Learn more how it works in View Transitions API - MDN Web Docs - Mozilla.
:::warning
Experimental: This is not supported by all browsers. Check the Browser compatibility table carefully before using this.
:::
You can use the view-transition-name CSS property to name view transitions, which creates connections between different page elements and smooth transitions when switching slides.
You can enable MDC (Markdown Component) Syntax support to conveniently name view-transitions:
---
transition: view-transition
mdc: true
---
# View Transition {.inline-block.view-transition-title}
---
# View Transition {.inline-block.view-transition-title}Custom Transitions
Slidev's slide transitions are powered by Vue Transition. You can provide your custom transitions by:
---
transition: my-transition
---and then in your custom stylesheets:
.my-transition-enter-active,
.my-transition-leave-active {
transition: opacity 0.5s ease;
}
.my-transition-enter-from,
.my-transition-leave-to {
opacity: 0;
}Learn more how it works in Vue Transition.
Forward & Backward Transitions
You can specify different transitions for forward and backward navigation using | as a separator in the transition name:
---
transition: go-forward | go-backward
---With this, when you go from slide 1 to slide 2, the go-forward transition will be applied. When you go from slide 2 to slide 1, the go-backward transition will be applied.
Advanced Usage
The transition field accepts an option that will passed to the `` component. For example:
---
transition:
name: my-transition
enterFromClass: custom-enter-from
enterActiveClass: custom-enter-active
---File: guide/drawing.md
Drawing & Annotations
Available since v0.23
drauu is built-in for drawing and annotation, should that help improve your presentation further.
To start, click the
Use with Stylus Pen
When using a stylus pen on a tablet (for example, iPad with Apple Pencil), Slidev will intelligently detect the input type. You can directly draw on your slides with the pen without turning on the drawing mode, while having your fingers or mouse control the navigation.
Persist Drawings
The following frontmatter configuration allows you to persist your drawings as SVGs under .slidev/drawings directory and have them inside your exported pdf or hosted site.
---
drawings:
persist: true
---Disable Drawings
Entirely:
---
drawings:
enabled: false
---Only in Development:
---
drawings:
enabled: dev
---Only in Presenter Mode:
---
drawings:
presenterOnly: true
---Drawing Syncing
By default, Slidev syncs up your drawings across all instances. If you are sharing your slides with others, you might want to disable the syncing via:
---
drawings:
syncAll: false
---With this config, only the drawing from the presenter instance will be able to sync with others.
File: guide/editors.md
Editor Support
Since Slidev uses Markdown as the source entry, you can use any editor you prefer to create your slides.
If you want some high-level management to your slides, we have provided the following editor integrations for you!
Integrated Editor
Slidev comes with an integrated editor that will instantly reload and save the changes to your file.
Click the
VS Code Extension
The VS Code extension provides some features to help you better organize your slides and have a quick overview of them.
Features
- Preview slides in the side panel
- Slides tree view
- Re-ordering slides
- Folding for slide blocks
- Multiple slides project support
- Start the dev server with one click
::: code-group
:::
Installation
You can install the extension from the VS Code Marketplace.
Usage
Click the Slidev icon in the activity bar to open the Slidev panel. In the Slidev panel, you can see the projects tree view, slides tree view, and the preview webview.
In the projects tree view, you can see all the Slidev projects in your workspace. You can dlick the item to open the corresponding file, and click the
In the slides tree view, you can see all the slides in the active project. You can click the item to move you cursor to the slide in the editor, and drag and drop to reorder the slides.
In the preview webview, you can click the
There are also some commands you can use. Type Slidev in the command palette to see them.
You can add glob patterns to the slidev.include configuration to include files as Slidev entries. The default value is ["**/*.md"]. Example:
{
"slidev.include": ["**/presentation.md"]
}Prettier Plugin
Slidev also provides a Prettier plugin to format your slides. You can use it with your favorite editor that supports Prettier. Docs for the plugin can be found here.
File: guide/exporting.md
Exporting
Slides
Exporting to PDF, PPTX, or PNG relies on Playwright for rendering. You will therefore need to install
playwright-chromiumto use this feature.
If you are exporting within a CI environment, the playwright CI guide can be helpful.
- Install
playwright-chromium:
$ npm i -D playwright-chromium- Now export your slides to PDF using the following command:
$ slidev exportAfter a few seconds, your slides will be ready at ./slides-export.pdf.
PNGs and Markdown
When passing in the --format png option, Slidev will export PNG images for each slide instead of a PDF:
$ slidev export --format pngYou can also compile a markdown file composed of compiled png using --format md:
$ slidev export --format mdPPTX (Microsoft PowerPoint)
Slidev can also export your slides as a PPTX file:
$ slidev export --format pptxNote that all the slides in the PPTX file will be exported as images, so the text will not be selectable. Presenter notes will be conveyed into the PPTX file on a per-slide basis.
In this mode, the --with-clicks option is enabled by default. To disable it, use --with-clicks false.
Dark mode
In case you want to export your slides using the dark version of the theme, use the --dark option:
$ slidev export --darkExport Clicks Steps
Available since v0.21
By default, Slidev exports one page per slide with clicks animations disabled. If you want to export slides with multiple steps into multiple pages, pass the --with-clicks option:
$ slidev export --with-clicksPDF outline
Available since v0.36.10
You can generate the PDF outline by passing the --with-toc option:
$ slidev export --with-tocOutput filename
You can specify the output filename with the --output option:
$ slidev export --output my-pdf-exportOr in the frontmatter configuration:
---
exportFilename: my-pdf-export
---Export a range of slides
By default, all slides in the presentation are exported. If you want to export a specific slide or a range of slides you can set the --range option and specify which slides you would like to export:
$ slidev export --range 1,6-8,10This option accepts both specific slide numbers and ranges.
The example above would export slides 1,6,7,8, and 10.
Multiple entries
You can also export multiple slides at once:
$ slidev export slides1.md slides2.mdOr
$ slidev export *.mdIn this case, each input file will generate its own PDF file.
Presenter notes
Available since v0.36.8
Export only the presenter notes (the last comment block for each slide) into a text document in PDF:
$ slidev export-notesThis command also accept multiple entries like for the export command
Single-Page Application (SPA)
See Static Hosting.
Exportable Docker Image
To support the export feature, there is a docker image (maintained by @tangramor) with tag playwright. Run following command in your work folder:
docker run --name slidev --rm -it \
-v ${PWD}:/slidev \
-p 3030:3030 \
-e NPM_MIRROR="https://registry.npmmirror.com" \
tangramor/slidev:playwrightThen you can use the export feature like the following under your work folder:
docker exec -i slidev npx slidev export --timeout 2m --output slides.pdfTroubleshooting
Timeouts
For big presentations you might want to increase the Playwright timeout with --timeout:
$ slidev export --timeout 60000Wait
Some parts of your slides may require a longer time to render. You can use the --wait option to have an extra delay before exporting:
$ slidev export --wait 10000There is also a --wait-until option to wait for a state before exporting each slide:
$ slidev export --wait-until nonePossible values:
'networkidle'- (default) consider operation to be finished when there are no network connections for at least500ms. Don't use this method for testing, rely on web assertions to assess readiness instead.'domcontentloaded'- consider operation to be finished when theDOMContentLoadedevent is fired.'load'- consider operation to be finished when theloadevent is fired.'none'- do not wait for any event.
::: warning
When specifying values other than 'networkidle', please make sure the printed slides are complete and correct. If some contents are missing, you may need to use the --wait option.
:::
Executable path
Chromium may miss some features like codecs that are required to decode some videos. You can set the browser executable path for Playwright to your Chrome or Edge using --executable-path:
$ slidev export --executable-path [path_to_chromium]File: guide/faq.md
FAQ
Grids
Since Slidev is based on the Web, you can apply any grid layouts as you want. CSS Grids, flexboxes, or even Masonry, you get the full controls.
Since UnoCSS is built-in, here's one way that you can reference:
The first column
The second columnGo further, you can customize the size of each column like:
The first column (200px)
The second column (auto fit)
The third column (10% width to parent container)Positioning
Slides are defined in fixed sizes (default 980x552px) and scale to fit with the user screen. You can safely use absolute position in your slides as they will scale along with the screen.
For example:
This is a left-bottom aligned footerTo change the canvas' actual size, you can pass the canvasWidth options in your first frontmatter:
---
canvasWidth: 800
---Font Size
If you feel the font size in your slides are too small, you can adjust it in a few ways:
Override Local Style
You can override styles for each slide with the inlined <style> tag.
# Page 1
<style>
h1 {
font-size: 10em;
}
</style>
---
# Page 2
This will not be affected.Learn more: Embedded Styles
Override Global Style
You can provide custom global styles by creating ./style.css, for example
/* style.css */
h1 {
font-size: 10em !important;
}Learn more: Global Style
Scale the Canvas
Changing the canvas' actual size will scale all your contents(text, images, components, etc.) and slides
---
# default: 980
# since the canvas gets smaller, the visual size will become larger
canvasWidth: 800
---Use Transform
We provide a built-in component ``, which is a thin wrapper of CSS transform property.
- Item 1
- Item 2