Skip to content

FAQ ​

Assets Handling ​

You may use static assets like images and videos in your slides. Since Slidev is based on Vite, you can import them directly in your markdown files.

URLs that can be statically analyzed as assets can use relative paths:

md
![alt](./image.png)
<img src="./image.png" />

In the above case, the URLs will be resolved to /BASE_URL/assets/image.png after build.

However, relative paths in frontmatter and other components will be broken after build:

md
---
background: ./image.png  # Broken after build
---

<Comp src="./image.png" />

In the above case, the URLs are not statically analyzable and will be preserved as-is, which will result in 404 errors after build.

To solve this, you can place these assets in the public folder and use an absolute path to import them:

md
---
background: /image.png
---

<Comp src="/image.png" />

For more details, refer to Vite's documentation.

Positioning ​

Since Slidev is web-based, CSS is the primary way to position elements. Here are some useful tips for position elements:

Grids And Flexboxes ​

You can use CSS Grids to create complex layouts:

md
<div class="grid grid-cols-2 gap-4">
  <div>
    The first column
  </div>
  <div>
    The second column
  </div>
</div>
md
<div class="grid grid-cols-[200px_1fr_10%] gap-4">
  <div>
    The first column (200px)
  </div>
  <div>
    The second column (auto fit)
  </div>
  <div>
    The third column (10% width to parent container)
  </div>
</div>

And use Flexboxes to create more responsive layouts:

md
<div class="flex items-center">

</div>
md
<div class="flex flex-col items-center">
  <div>
    Centered content
  </div>
</div>

Learn more: CSS Grids, flexboxes, or even Masonry,

Absolute Position ​

You can use UnoCSS to position elements absolutely:

md
<div class="absolute left-30px bottom-30px">
  This is a left-bottom aligned footer
</div>

Or use the draggable elements feature:

Move, resize, and rotate elements by dragging them with the mouse.

Adjust Sizes ​

  • Adjust all slides's size:
Set the size for all your slides.
  • Adjust several slides' size:
Zoom the content of a slide to a specific scale.
  • Adjust some elements' size:
A component for scaling some elements.

Released under the MIT License.