/void !

Slidev

2 min read

InstallationπŸ”—

Create a new projectπŸ”—

# Recommended with pnpm
pnpm create slidev

# Alternatives
npm init slidev@latest
yarn create slidev
bun create slidev

PrerequisitesπŸ”—

  • Node.js >= 18.0

Basic commandsπŸ”—

slidev                  # Start development server
slidev export          # Export to PDF/PPTX/PNG
slidev build           # Build static web application
slidev format          # Format slides
slidev --help          # Show help

Basic structureπŸ”—

slides.md fileπŸ”—

---
theme: seriph
title: My presentation
background: /background.jpg
---

# Presentation title
Subtitle or description

---

# Second slide

Slide content

Slide separationπŸ”—

---
# New slide with triple dash separator

---

# Another slide

FrontmatterπŸ”—

Global configuration (first slide)πŸ”—

---
theme: default              # Theme
background: /cover.jpg      # Background image
class: text-center          # CSS classes
highlighter: shiki          # Syntax highlighter
lineNumbers: false          # Line numbering
info: |                     # Metadata
  ## My presentation
  Additional information
drawings:
  persist: false            # Drawing persistence
transition: slide-left      # Slide transitions
title: Title                # Presentation title
mdc: true                   # Enable MDC syntax
---

Per-slide configurationπŸ”—

---
layout: center              # Slide layout
background: /image.jpg      # Specific background
class: text-white           # CSS classes
transition: fade            # Specific transition
clicks: 3                   # Number of clicks
---

Built-in layoutsπŸ”—

Layout centerπŸ”—

---
layout: center
---

# Centered content
Text in the center of the screen

Layout cover (cover page)πŸ”—

---
layout: cover
background: /cover.jpg
---

# Main title
Presentation description

Layout two-cols (two columns)πŸ”—

---
layout: two-cols
---

# Left column
Left content

::right::

# Right column
Right content

Layout image-left / image-rightπŸ”—

---
layout: image-left
image: /path/to/image.jpg
---

# Content on the right
Image displays on the left
---
layout: image-right
image: /path/to/image.jpg
---

# Content on the left
Image displays on the right

Layout quoteπŸ”—

---
layout: quote
---

# "Important quote"
β€” Author

Layout sectionπŸ”—

---
layout: section
---

# New section
Marks the beginning of a new section

Layout factπŸ”—

---
layout: fact
---

# 1,000,000+
Active users

Layout iframe-left / iframe-rightπŸ”—

---
layout: iframe-right
url: https://example.com
---

# Embed a website
Iframe displays on the right

Layout statementπŸ”—

---
layout: statement
---

# Important statement
Key message of the presentation

Layout defaultπŸ”—

---
layout: default
---

# Default layout
Standard content

Layout fullπŸ”—

---
layout: full
---

# Full screen
Uses all available space

Layout noneπŸ”—

---
layout: none
---

No style applied

Layout introπŸ”—

---
layout: intro
---

# Introduction title
## Author
Description

Layout endπŸ”—

---
layout: end
---

# Thank you!
Questions?

Code blocksπŸ”—

Basic code with syntax highlightingπŸ”—

​```python
def hello():
    print("Hello Slidev!")
​```

Code with line highlightingπŸ”—

​```python {2-3}
def hello():
    print("Hello Slidev!")  # Highlighted line
    print("Line 3")         # Highlighted line
    print("Line 4")
​```

Code with multiple highlighting stepsπŸ”—

​```python {2|3|all}
def hello():
    print("Step 1")  # Displayed on 1st click
    print("Step 2")  # Displayed on 2nd click
                    # 'all' displays everything on 3rd click
​```

Monaco editor (interactive code)πŸ”—

​```ts {monaco}
console.log('Editable code!')
​```

Monaco editor with executionπŸ”—

​```ts {monaco-run}
console.log('Executable code')
​```

AnimationsπŸ”—

v-click (show on click)πŸ”—

<v-click>

Appears on first click

</v-click>

<v-click>

Appears on second click

</v-click>

v-after (show after previous)πŸ”—

<v-click>Element 1</v-click>
<v-after>Element 2 (appears right after)</v-after>

v-click with hidingπŸ”—

<v-click :hide="true">

This element disappears on click

</v-click>

v-clicks (animate a list)πŸ”—

<v-clicks>

- Item 1 (click 1)
- Item 2 (click 2)
- Item 3 (click 3)

</v-clicks>

v-clicks with depthπŸ”—

<v-clicks depth="2">

- Level 1 (click 1)
  - Level 2 (click 2)
  - Level 2 (click 3)

</v-clicks>

v-click on inline elementπŸ”—

Normal text <span v-click>appearing text</span> normal text

v-click with precise timingπŸ”—

<div v-click="1">Appears on click 1</div>
<div v-click="3">Appears on click 3</div>
<div v-click="2">Appears on click 2</div>

v-click with rangeπŸ”—

<div v-click="[2, 4]">
  Visible between clicks 2 and 4
</div>

Motion animations (v-motion)πŸ”—

Basic animationπŸ”—

<div
  v-motion
  :initial="{ x: -80 }"
  :enter="{ x: 0 }">
  Slide from the left
</div>

Complete animation with clicksπŸ”—

<div
  v-motion
  :initial="{ x: -80, opacity: 0 }"
  :enter="{ x: 0, opacity: 1, transition: { delay: 100 } }"
  :click-1="{ x: 80 }"
  :click-2="{ y: -50, opacity: 0 }"
  :leave="{ x: 1000 }">
  Complex animation
</div>

Available animation propertiesπŸ”—

<div
  v-motion
  :initial="{
    x: 0,           # X position
    y: 0,           # Y position
    scale: 1,       # Scale
    rotate: 0,      # Rotation (degrees)
    opacity: 1      # Opacity
  }"
  :enter="{
    x: 100,
    transition: {
      duration: 500,  # Duration in ms
      delay: 100,     # Delay in ms
      ease: 'easeOut' # Easing type
    }
  }">
  Animated element
</div>

Slide transitionsπŸ”—

Global transitionsπŸ”—

---
transition: slide-left    # fade, slide-left, slide-right, slide-up, slide-down
---

Per-slide transitionsπŸ”—

---
transition: fade
---

Custom transitions (forward/backward)πŸ”—

---
transition: slide-left|slide-right  # slide-left forward, slide-right backward
---

Built-in componentsπŸ”—

ArrowπŸ”—

<Arrow x1="10" y1="20" x2="100" y2="200" />

AutoFitText (adaptive text)πŸ”—

<AutoFitText :max="200" :min="100" modelValue="Large text" />

LightOrDark (light/dark theme conditional)πŸ”—

<LightOrDark>
  <template #dark>Dark mode content</template>
  <template #light>Light mode content</template>
</LightOrDark>
<Link to="5">Go to slide 5</Link>
<Link to="5" title="Link title" />

RenderWhen (conditional rendering)πŸ”—

<RenderWhen context="main">
  Displayed only in main presentation
</RenderWhen>

<RenderWhen context="presenter">
  Displayed only in presenter mode
</RenderWhen>

SlideCurrentNo (slide number)πŸ”—

Slide <SlideCurrentNo /> / <SlidesTotal />

Toc / TocList (table of contents)πŸ”—

<Toc />

# Or with options
<TocList maxDepth="2" minDepth="1" />

TransformπŸ”—

<Transform :scale="0.5">
  <YourElements />
</Transform>

<Transform :rotate="45" origin="top left">
  Rotated element
</Transform>

Tweet (embed tweet)πŸ”—

<Tweet id="1234567890" />

VueSlideCore (custom Vue slide)πŸ”—

<VueSlideCore :page="5" />

Youtube (YouTube video)πŸ”—

<Youtube id="dQw4w9WgXcQ" width="100%" height="400px" />

Presenter notesπŸ”—

---
layout: center
---

# My slide

Visible content

<!--
This is a presenter note
Visible only in presenter mode
-->

Mathematical formulas (LaTeX)πŸ”—

InlineπŸ”—

Inline formula: $E = mc^2$

BlockπŸ”—

$$
\frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x)
$$

DiagramsπŸ”—

MermaidπŸ”—

​```mermaid
graph TD
  A[Start] --> B[Process]
  B --> C[End]
​```

PlantUMLπŸ”—

​```plantuml
@startuml
Alice -> Bob: Hello
Bob -> Alice: Hi!
@enduml
​```

Style and CSSπŸ”—

Global CSS classesπŸ”—

---
class: text-center text-2xl
---

Slide-scoped CSSπŸ”—

---
layout: center
---

# My slide

<style>
h1 {
  color: red;
}
</style>

UnoCSS classesπŸ”—

<div class="text-3xl text-blue-500 font-bold">
  Text styled with UnoCSS
</div>

MDC syntax (Markdown Components)πŸ”—

Add classes and attributesπŸ”—

# Title 

[Link]

![Image](/img.jpg)

Components with propsπŸ”—

::component-name{prop1="value" prop2="value"}
Content
::

IconsπŸ”—

With UnoCSSπŸ”—

<div class="i-carbon-logo-github" />
<div class="i-mdi-account text-3xl text-red-500" />

BackgroundsπŸ”—

Background imageπŸ”—

---
background: /path/to/image.jpg
---

Background colorπŸ”—

---
background: '#1e1e1e'
---

GradientπŸ”—

---
background: linear-gradient(to right, #ff0000, #0000ff)
---

Video backgroundπŸ”—

---
background: /video.mp4
---

Import external slidesπŸ”—

Import a fileπŸ”—

---
src: ./external-slides.md
---

Import a range of slidesπŸ”—

---
src: ./external-slides.md
pages: 1-5
---

Presenter modeπŸ”—

  • Press ? to see all keyboard shortcuts
  • Presenter notes visible only in presentation mode
  • Next slide preview
  • Timer and clock

Essential keyboard shortcutsπŸ”—

KeyAction
Space / β†’Next slide
←Previous slide
↑Previous slide (no animations)
↓Next slide (no animations)
HomeFirst slide
EndLast slide
fFullscreen
oOverview
dDark mode
gShow/hide camera
rRecording
eDrawing mode
cPresenter notes
?Show all shortcuts

ExportπŸ”—

PDFπŸ”—

slidev export

# With options
slidev export --format pdf --output slides.pdf

PNGπŸ”—

slidev export --format png

PPTXπŸ”—

slidev export --format pptx

Export optionsπŸ”—

slidev export --dark           # Dark mode
slidev export --with-clicks    # Include animations
slidev export --timeout 30000  # Render timeout

Build for productionπŸ”—

slidev build

# With base path
slidev build --base /slides/

HostingπŸ”—

Built slides can be hosted on any static server:

  • GitHub Pages
  • Netlify
  • Vercel
  • Custom server

Advanced configurationπŸ”—

vite.config.ts fileπŸ”—

import { defineConfig } from 'vite'

export default defineConfig({
  slidev: {
    // Slidev options
  }
})

Custom themesπŸ”—

---
theme: ./custom-theme
---

AddonsπŸ”—

Install addons via npm and configure them in frontmatter:

---
addons:
  - slidev-addon-example
---

TipsπŸ”—

Disable animationsπŸ”—

---
clicks: 0  # No clicks on this slide
---

Aspect ratioπŸ”—

---
aspectRatio: '16/9'  # or '4/3'
---

Global line numberingπŸ”—

---
lineNumbers: true
---

Custom faviconπŸ”—

Place public/favicon.ico in the project

Custom fontsπŸ”—

---
fonts:
  sans: 'Robot'
  serif: 'Robot Slab'
  mono: 'Fira Code'
---

ResourcesπŸ”—

  • Official documentation: https://sli.dev
  • GitHub: https://github.com/slidevjs/slidev
  • Themes: https://sli.dev/themes/gallery.html
  • Addons: https://sli.dev/addons/use.html